evnbr / bindery

Book layout in the browser
https://bindery.info
MIT License
410 stars 38 forks source link

RunningHeader displaying footnote marker from heading #7

Open teddybradford opened 7 years ago

teddybradford commented 7 years ago

If footnotes are applied to a link in a header, the RunningHeader will display the superscript number. e.g., <h1><a href="">Title</a></h1> will show as "Title1" in the running header given the following:

Bindery.Footnote({
  selector: "a",
  render: (el, number) => `<span class="footnote"><sup>${ number }</sup><a href="${ el.href }">${ el.href }</a></span>`,
}),
Bindery.RunningHeader({
  render: (page) => {
    if (page.isEmpty) return "";
    else if (page.element.querySelector("h1")) return "";
    else if (page.isLeft) return `<div class="running-header"><span class="page-number">${ page.number }</span> ${ page.heading.h1 }</div>`;
  },
}),
evnbr commented 7 years ago

lol good catch. if it showed the original header would that be sufficient? or would you want to specify running headers that don't correspond to the text of the h1-h6 tags?

teddybradford commented 7 years ago

Being able to specify a query selector would be useful so you could do things like page.heading[".chapter-title"] + ": " + page.heading.h1 for the running header.