all repos — hastyscribe @ 1e0e11b7d49d4cac54d61f41ecc3d142c89ee9ef

A professional markdown compiler.

Added support for document headings.
h3rald h3rald@h3rald.com
Fri, 06 Dec 2013 20:00:19 +0100
commit

1e0e11b7d49d4cac54d61f41ecc3d142c89ee9ef

parent

48c81d9339c2ea12e5f58e901536f0db347a9c84

2 files changed, 83 insertions(+), 3 deletions(-)

jump to
A assets/headings.css

@@ -0,0 +1,75 @@

+h2 { + counter-reset:h3; + counter-increment: h2; +} +h2::before { + content: counter(h2) " " "\2013" " "; +} +h3 { + counter-reset:h4; + counter-increment: h3; +} +h3::before { + content: counter(h2) "." counter(h3) " " "\2013" " "; +} +h4 { + counter-reset:h5; + counter-increment: h4; +} +h4::before { + content: counter(h2) "." counter(h3) "." counter(h4) " " "\2013" " "; +} +h5 { + counter-reset:h6; + counter-increment: h5; +} +h5::before { + content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) " " "\2013" " "; +} +h6 { + counter-increment: h6; +} +h6::before { + content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) "." counter(h6) " " "\2013" " "; +} + +/***************/ + +#toc { + counter-reset: toc2; +} + +#toc li li a { + counter-reset:toc3; + counter-increment: toc2; +} +#toc li li a::before { + content: counter(toc2) " " "\2013" " "; +} +#toc li li li a { + counter-reset:toc4; + counter-increment: toc3; +} +#toc li li li a::before { + content: counter(toc2) "." counter(toc3) " " "\2013" " "; +} +#toc li li li li a { + counter-reset:toc5; + counter-increment: toc4; +} +#toc li li li li a::before { + content: counter(toc2) "." counter(toc3) "." counter(toc4) " " "\2013" " "; +} +#toc li li li li li a { + counter-reset:toc6; + counter-increment: toc5; +} +#toc li li li li li a::before { + content: counter(toc2) "." counter(toc3) "." counter(toc4) "." counter(toc5) " " "\2013" " "; +} +#toc li li li li li li a { + counter-increment: toc6; +} +#toc li li li li li li a::before { + content: counter(toc2) "." counter(toc3) "." counter(toc4) "." counter(toc5) "." counter(toc6) " " "\2013" " "; +}
M hastyscribe.nimhastyscribe.nim

@@ -15,6 +15,7 @@ --notoc Do not generate a Table of Contents."""

var generate_toc = true const src_css = "assets/hastyscribe.css".slurp +const src_headings_css = "assets/headings.css".slurp const src_highlight_js = "assets/highlight.pack.js".slurp # Procedures

@@ -49,7 +50,8 @@

# Document Variables var metadata = TMDMetaData(title:"", author:"", date:"") var body = source.md(MKD_DOTOC or MKD_EXTRA_FOOTNOTE, metadata) - let css = src_css.style_tag + var main_css = src_css.style_tag + var headings_css = src_headings_css.style_tag # Manage metadata if metadata.author != "":

@@ -67,6 +69,7 @@

if generate_toc == true and metadata.toc != "": toc = "<div id=\"toc\">" & metadata.toc & "</div>" else: + headings_css = "" toc = "" # Date parsing and validation

@@ -86,7 +89,8 @@ <meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="author" content="$author"> <meta name="generator" content="HastyScribe"> - $css + $main_css + $headings_css </head> <body> $header_tag

@@ -102,9 +106,10 @@ $highlight

hljs.tabReplace = ' '; hljs.initHighlighting(); </script> -</body>""" % ["title_tag", title_tag, "header_tag", header_tag, "author", metadata.author, "date", timeinfo.format("MMMM d, yyyy"), "toc", toc, "css", css, "body", body, "highlight", src_highlight_js] +</body>""" % ["title_tag", title_tag, "header_tag", header_tag, "author", metadata.author, "date", timeinfo.format("MMMM d, yyyy"), "toc", toc, "main_css", main_css, "headings_css", headings_css, "body", body, "highlight", src_highlight_js] output_file.writeFile(document) + ### MAIN