all repos — h3rald @ f5a34f008925c3f1df94d98a544b9016a6628b79

The sources of https://h3rald.com

Started implementing automatic toc for articles.
h3rald h3rald@h3rald.com
Sat, 16 Mar 2024 16:56:12 +0100
commit

f5a34f008925c3f1df94d98a544b9016a6628b79

parent

75b993c50cb2573b6f1aae6b658b13ac891877a9

1 files changed, 18 insertions(+), 0 deletions(-)

jump to
M rules.minrules.min

@@ -189,6 +189,23 @@ ) replace-apply @result

) ) :: +( + symbol prepend-toc + (str :text ==> str :result) + ( + () :headings + text "<h([1-6])[^>]*>([^<]+)</h[1-6]>" ( + :matches + matches 1 get :level + matches 2 get :title + title "[^a-zA-Z0-9_-]" "_" replace :id + "heading__$#" (id) =% @id + (id title) headings append @headings + "<h$1 id='$2'>$3</h$1>" (level id title) =% + ) replace-apply @result + ) +) :: + ; Process :icon: markup ( symbol process-icons

@@ -247,6 +264,7 @@ content contents %contents @content

tpl content mustache @page id page process-icons @page id page process-code @page + page prepend-toc @page content page %contents @content ( ((id "^(glyph|ruby-compendium)(\/|\\\\)book" match?) ()) ;Do not add index.html due to the way book internal links work.