all repos — hastyscribe @ 66f8e8f866ae3dd3c9f53d8558e9adc6c4f06817

A professional markdown compiler.

Implemented --noembed flag; incremented version number.
h3rald h3rald@h3rald.com
Tue, 29 Aug 2023 16:18:33 +0200
commit

66f8e8f866ae3dd3c9f53d8558e9adc6c4f06817

parent

5dfde4411ee93ef63f38723c11030ec4f8788070

2 files changed, 16 insertions(+), 6 deletions(-)

jump to
M src/hastyscribe.nimsrc/hastyscribe.nim

@@ -30,6 +30,7 @@ css*: string

js*: string watermark*: string fragment*: bool + embed*: bool HastyFields* = Table[string, string] HastySnippets* = Table[string, string] HastyMacros* = Table[string, string]

@@ -344,7 +345,7 @@ # Parse transclusions, fields, snippets, and macros

hs.document = hs.preprocess(hs.document, dir) # Document Variables var - main_css_tag = stylesheet.style_tag + main_css_tag = "" user_css_tag = "" user_js_tag = "" watermark_css_tag = ""

@@ -389,6 +390,11 @@ try:

timeinfo = parse(metadata.date, "yyyy-MM-dd") except CatchableError: timeinfo = parse(getDateStr(), "yyyy-MM-dd") + + var embedded_fonts = "" + if hs.options.embed: + main_css_tag = stylesheet.style_tag + embedded_fonts = embed_fonts() hs.document = """<!doctype html> <html lang="en">

@@ -419,8 +425,9 @@ </div>

</div> $js </body>""" % ["title_tag", title_tag, "header_tag", header_tag, "author", metadata.author, "author_footer", author_footer, "date", timeinfo.format("MMMM d, yyyy"), "toc", toc, "main_css_tag", main_css_tag, "user_css_tag", user_css_tag, "headings", headings, "body", hs.document, -"fonts_css_tag", embed_fonts(), "internal_css_tag", metadata.css, "watermark_css_tag", watermark_css_tag, "js", user_js_tag] - hs.embed_images(dir) +"fonts_css_tag", embedded_fonts, "internal_css_tag", metadata.css, "watermark_css_tag", watermark_css_tag, "js", user_js_tag] + if hs.options.embed: + hs.embed_images(dir) hs.document = add_jump_to_top_links(hs.document) return hs.document

@@ -463,6 +470,7 @@ --user-js=<file> Insert contents of <file> as a Javascript script.

--output-file=<file> Write output to <file>. (Use "--output-file=-" to output to stdout) --watermark=<file> Use the image in <file> as a watermark. + --noembed If specified, styles and images will not be embedded. --fragment If specified, an HTML fragment will be generated, without embedding images, fonts, or stylesheets. --dump=all|styles|fonts Dumps all resources/stylesheets/fonts to the current directory.

@@ -471,7 +479,7 @@

var input = "" var files = newSeq[string](0) - var options = HastyOptions(toc: true, output: "", css: "", watermark: "", fragment: false) + var options = HastyOptions(toc: true, output: "", css: "", watermark: "", fragment: false, embed: true) var fields = initTable[string, string]() var dumpdata = ""

@@ -490,6 +498,8 @@ quit(7)

dumpdata = val of "notoc": options.toc = false + of "noembed": + options.embed = false of "user-css": options.css = val of "user-js":

@@ -533,4 +543,4 @@ hs.compile(file)

except IOError: let msg = getCurrentExceptionMsg() fatal msg - quit(3)+ quit(3)
M src/hastyscribepkg/config.nimsrc/hastyscribepkg/config.nim

@@ -1,4 +1,4 @@

const - pkgVersion* = "1.12.5" + pkgVersion* = "2.0.0" pkgAuthor* = "Fabio Cevasco" pkgDescription* = "Self-contained markdown compiler generating self-contained HTML documents"