Commit 5cb2d2a
Changed files (2)
src
contents
_lib
templates
src/contents/_lib/templates/footnote.typ
@@ -1,30 +1,30 @@
-#let side-footnote(body) = {
- show footnote: it => context {
- if target() == "html" {
- let number = counter(footnote).display(it.numbering)
- let fn-id = "fn-" + number
- let ref-id = "fnref-" + number
+#import "@preview/bullseye:0.1.0": show-target
- html.sup(
- id: ref-id,
- html.a(
- href: "#" + fn-id,
- number,
- ),
- )
- html.span(
- class: "marginnote",
- id: fn-id,
- html.sup(html.a(href: "#" + ref-id, number)) + [ ] + it.body,
- )
- }
+#let side-footnote-html(body) = {
+ show footnote: it => {
+ let number = counter(footnote).display(it.numbering)
+ let fn-id = "fn-" + number
+ let ref-id = "fnref-" + number
+
+ html.sup(
+ id: ref-id,
+ html.a(
+ href: "#" + fn-id,
+ number,
+ ),
+ )
+ html.span(
+ class: "marginnote",
+ id: fn-id,
+ html.sup(html.a(href: "#" + ref-id, number)) + [ ] + it.body,
+ )
}
body
}
#let footnote-template(body) = {
- show: side-footnote
+ show: show-target(html: side-footnote-html)
body
}
src/contents/_lib/templates/heading.typ
@@ -1,27 +1,26 @@
-#import "../utils/slugger.typ": slugger
+#import "@preview/bullseye:0.1.0": show-target
-#let auto-reslugify-headings(body) = context {
- if target() == "html" {
- let headings-slug-record = state("headings-slug-record", (:))
- show heading: it => {
- let record = headings-slug-record.get()
- let ((slug,), record) = slugger(it.body, record: record)
- slug = "heading-" + slug
- headings-slug-record.update(record)
+#import "../utils/slugger.typ": slugger
- html.elem(
- "h" + str(it.level + 1),
- attrs: (id: slug),
- it.body,
- )
- }
+#let auto-reslugify-headings(body) = {
+ let headings-slug-record = state("headings-slug-record", (:))
+ show heading: it => context {
+ let record = headings-slug-record.get()
+ let ((slug,), record) = slugger(it.body, record: record)
+ slug = "heading-" + slug
+ headings-slug-record.update(record)
+ html.elem(
+ "h" + str(it.level + 1),
+ attrs: (id: slug),
+ it.body,
+ )
+ }
- body
- } else { body }
+ body
}
#let heading-template(body) = {
- show: auto-reslugify-headings
+ show: show-target(html: auto-reslugify-headings)
body
}