diff options
| author | Shulhan <ms@kilabit.info> | 2026-03-30 21:30:00 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2026-03-30 21:30:00 +0700 |
| commit | f9d7f5a462ef3ba6d07f0f13af6816badcea09e1 (patch) | |
| tree | c813b235fa4d6881df51c7b12a1997f21b516f18 /html_backend.go | |
| parent | 4d0204028e90ecd60c74f426456c901367491ed9 (diff) | |
| download | asciidoctor-go-f9d7f5a462ef3ba6d07f0f13af6816badcea09e1.tar.xz | |
all: move the sect anchor element to the right
Previously, we try to fix the anchor position by using "flex-direction:
row-reverse".
This cause the formatted text inside title also become reversed.
For example,
== With `mono`
Will rendered as
mono With $
This is not as expected.
This changes fix this by rendering the anchor on the right after title.
Diffstat (limited to 'html_backend.go')
| -rw-r--r-- | html_backend.go | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/html_backend.go b/html_backend.go index 323b60b..32973e0 100644 --- a/html_backend.go +++ b/html_backend.go @@ -1160,18 +1160,7 @@ func htmlWriteSection(doc *Document, el *element, out io.Writer) { fmt.Fprintf(out, "\n<div class=%q>\n<%s id=%q>", class, tag, el.ID) - var ( - withSectAnchors bool - withSectlinks bool - ) - - _, withSectAnchors = doc.Attributes.Entry[docAttrSectAnchors] - if withSectAnchors { - fmt.Fprintf(out, - `<a class="anchor" href="#%s" aria-label="Anchor for %s"></a>`, - el.ID, el.ID) - } - _, withSectlinks = doc.Attributes.Entry[docAttrSectLinks] + _, withSectlinks := doc.Attributes.Entry[docAttrSectLinks] if withSectlinks { fmt.Fprintf(out, `<a class="link" href="#%s">`, el.ID) } @@ -1185,6 +1174,13 @@ func htmlWriteSection(doc *Document, el *element, out io.Writer) { if withSectlinks { fmt.Fprint(out, "</a>") } + + _, withSectAnchors := doc.Attributes.Entry[docAttrSectAnchors] + if withSectAnchors { + fmt.Fprintf(out, + `<a class="anchor" href="#%s" aria-label="Anchor for %s"></a>`, + el.ID, el.ID) + } fmt.Fprintf(out, "</%s>", tag) if el.kind == elKindSectionL1 { |
