Skip to main content

Module html

Module html 

Source
Expand description

The lowering rules of the xnotes feature for the html backend, and the feature’s stylesheet.

On the HTML page, an xnote and a list of xnotes are written with the same presentation elements as on every other output: the rules of this module call the staging helpers of the general rules (stage_mark, stage_in_place, ListRule), so that the page writes the same structure as the other outputs that use these shapes, and the HTML backend writes those elements as its HTML contract states (the classes and attributes a stylesheet may rely on; see CONVENTIONS and the HTML contract). The rules of this module are marked default on the html backend and add what only the page needs:

  • the link back from each entry of a list of xnotes to its mark (ListHtmlRule);
  • no bracket text around an xnote shown in place (XnoteHtmlRule): the stylesheet draws the brackets, so that a page’s own stylesheet can replace them;
  • the stylesheet STYLE (flm.xnotes.style). The staging helpers that the general rules and these rules share require the feature’s style identifier STYLE at every xnote and every list: they record it as a requirement of the output, and on this backend it names the stylesheet, which the backend then writes or loads (see StyleDef).

§The markup

The worked example, The claim holds in every case.\footnote{Except the empty one, which we exclude by convention.} The next sentence goes on., writes the mark as a superscript carrying the mark’s anchor (its id), around a link to the xnote. The link carries the document role doc-noteref and an accessible name (the name that assistive technology reads in place of the link’s text), so that a screen reader announces “Footnote 1” rather than “1”:

<p class="flm-pres-par">The claim holds in every case.<sup class="flm-pres-span flm-xnotes-xnote-mark" id="fnref--1yuhk" data-flm-style="superscript"><a class="flm-pres-link" href="#fn-1" role="doc-noteref" aria-label="Footnote 1" data-flm-kind="xnote">1</a></sup> The next sentence goes on.</p>

The list of the xnote kind is placed after the document’s content: a block of the document role doc-endnotes holding the title as a heading and a labeled list whose entries carry the xnotes’ anchors. The last paragraph of each entry ends with a link back to the mark, of the role doc-backlink, whose text is the kind’s backlink (↩) and whose accessible name is Back to followed by the xnote’s name as a reference writes it:

<div class="flm-pres-block flm-xnotes-footnote-list" role="doc-endnotes" data-flm-kind="xnotes footnote">
  <h2 class="flm-pres-block--heading" data-flm-heading="xnotes" data-flm-level="2" data-flm-toc="false">Footnotes</h2>
  <ol class="flm-pres-list" data-flm-kind="numbered xnotes footnote labeled">
    <li id="fn-1"><span class="flm-pres-list-label"><sup class="flm-pres-span flm-xnotes-entry-mark" data-flm-style="superscript">1</sup></span>
      <p class="flm-pres-par">Except the empty one, which we exclude by convention. <a class="flm-pres-link" href="#fnref--1yuhk" role="doc-backlink" aria-label="Back to Footnote 1" data-flm-kind="xnote-back">↩</a></p>
    </li>
  </ol>
</div>

The heading is written with the tag of its level, or with the tag to which the render option heading_tags maps the heading name xnotes (TITLE_HEADING). Where the plan computes no anchors (in a registry without the references feature), the mark has no link and the entry no link back.

An xnote of a kind shown in place is one span where its content is inline, carrying the xnote’s anchor, its kind tokens and the document role doc-footnote, with the mark inside it and no link:

…every case. <span class="flm-pres-span flm-xnotes-xnote-inplace" id="fn-1" role="doc-footnote" data-flm-kind="xnotes footnote"><sup class="flm-pres-span flm-xnotes-xnote-mark" id="fnref--1yuhk" data-flm-style="superscript">1</sup>Except the empty one, which we exclude by convention.</span> The next…

Where its content holds paragraphs, it is a block, as a list is: the paragraph it is written in ends before it, the text after it is a new paragraph, and its mark is at the head of its first paragraph:

<p class="flm-pres-par">Two paragraphs.</p>
<div class="flm-pres-block flm-xnotes-xnote-inplace" id="fn-1" role="doc-footnote" data-flm-kind="xnotes footnote">
  <p class="flm-pres-par"><sup class="flm-pres-span flm-xnotes-xnote-mark" id="fnref--1yuhk" data-flm-style="superscript">1</sup>First paragraph.</p>
  <p class="flm-pres-par">Second paragraph.</p>
</div>
<p class="flm-pres-par">And on.</p>

The mark of an unnumbered xnote kind is its fixed mark, and an empty fixed mark gives an empty <sup>, so that the mark’s anchor still exists.

§The stylesheet

The style definition stylesheet (flm.xnotes.style; see StyleDef) is one cascade layer holding the line above a list of xnotes, with a space between the line and the list’s content, and the brackets around an xnote shown in place, and nothing more. Every value it uses is a custom property declared in it (--flm-xnotes-list-rule, --flm-xnotes-list-size, --flm-xnotes-list-space, --flm-xnotes-list-padding, --flm-xnotes-inplace-open, --flm-xnotes-inplace-close), which a page sets to change these values without writing a rule of its own. The xnote and the list require it, so a page holding no xnote does not carry it.

The feature ships no script. An xnote shown in place is always written whole, with every anchor, role and kind token as an attribute, so that a page’s own stylesheet or script can lay it out, hide it or show it; a script shipped by the feature would interfere with the page’s own. A host adds a stylesheet or a script of its own by declaring a style or script definition in a feature of its own (FeatureBuilder::style_def, script_def) and requiring it from a rule, or replaces the content of this stylesheet through the render option definitions.

§Registration

The rules are marked default on the html backend only, and are registered under a peer declaration (PeerName) of that backend, so that a registry without the backend still builds, with the rules set aside (excluded from rule selection). The xnotes feature registers the stylesheet and, where a configured xnote kind has a command, the xnote’s rule (html_rule); contribute_kind registers the list’s rule for each xnote kind, like every rule of a kind’s list.

Structs§

ListHtmlRule
The lowering rule of an xnote kind’s list element on the html backend (list_rule_name): the list as the general rule writes it (ListRule), with the link back to each xnote’s mark at the end of the last paragraph of its entry. It requires the style identifier STYLE, as the general rule does.
XnoteHtmlRule
The lowering rule of an xnote on the html backend, HTML_RULE: the xnote’s mark, or the xnote in place, as the general rule writes them (stage_mark, stage_in_place), but with no bracket text, because the stylesheet draws the brackets. It requires the style identifier STYLE and reports the refused content of the optional argument as the general rule does.

Constants§

BACKLINK_LABEL_PREFIX
The words with which the accessible name of an entry’s link back to its mark begins, before the xnote’s name: Back to.
HTML_RULE
The name of the lowering rule of an xnote on the html backend, flm.xnotes.xnote.lower.html (XnoteHtmlRule).

Functions§

html_rule
The lowering rule of an xnote on the html backend, HTML_RULE (XnoteHtmlRule), marked default on that backend only.
list_rule_name
The name of the lowering rule of the list element of the xnote kind kind on the html backend, flm.xnotes.<kind>.list.lower.html (ListHtmlRule).
stylesheet
The feature’s style definition, flm.xnotes.style (STYLE): the line above a list of xnotes and the brackets around an xnote shown in place, in one cascade layer, with every value a custom property it declares. The xnotes feature registers it; the xnote and the list require it. See the module documentation.