all repos — hastyscribe @ b18a13d9e9513e2cceb6d92a1a7dd5e39a3029d1

A professional markdown compiler.

Implemented the possibility to embed a custom Javascript file; could be
useful for syntax highlighting. Closes #9.
h3rald h3rald@h3rald.com
Sat, 18 Feb 2017 16:01:24 +0100
commit

b18a13d9e9513e2cceb6d92a1a7dd5e39a3029d1

parent

fe61b9a88233c76c6500f0294d46b1a04dcb761d

M README.mdREADME.md

@@ -18,7 +18,8 @@ * _filename-or-glob-expression_ is a valid file or [glob](http://en.wikipedia.org/wiki/Glob_(programming)) expression that will be compiled into HTML.

* The following options are supported: * **\-\-field/<field>=<value>** causes HastyScribe to set a custom field to a specific value. * **\-\-notoc** causes HastyScribe to output HTML documents _without_ automatically generating a Table of Contents at the start. - * **\-\-user-css=<file>** causes HastyScribe inserts the contents of the specified local file as a CSS stylesheet. + * **\-\-user-css=<file>** causes HastyScribe to insert the contents of the specified local file as a CSS stylesheet. + * **\-\-user-js=<file>** causes HastyScribe to insert the contents of the specified local file as a Javascript script. * **\-\-output-file=<file>** causes HastyScribe to write output to a local file (Use [\-\-output-file=-](class:opt) to output to standard output). * **\-\-watermark=<file>** causes HastyScribe to embed and display an image as a watermark throughout the document. * **\-\-fragment** causes HastyScribe to output just an HTML fragment instead of a full document, without embedding any image, font or stylesheet.
M build_guidebuild_guide

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

-./hastyscribe doc/HastyScribe_UserGuide.md --field/version=1.4.0 +./hastyscribe doc/HastyScribe_UserGuide.md --field/version=1.5.0
M doc/HastyScribe_UserGuide.htmdoc/HastyScribe_UserGuide.htm

@@ -268,11 +268,11 @@

<p>The easiest way to get HastyScribe is by downloading one of the prebuilt binaries from the <a href="https://github.com/h3rald/hastyscribe/releases/download/v">Github Release Page</a>:</p> <ul> -<li><a href="https://github.com/h3rald/hastyscribe/releases/download/v1.4.0/hastyscribe_v1.4.0_macos_x64.zip">HastyScribe for Mac OS X (x64)</a> &ndash; Compiled on Mac OS X Sierra (LLVM CLANG 8.0.0)</li> -<li><a href="https://github.com/h3rald/hastyscribe/releases/download/v1.4.0/hastyscribe_v1.4.0_windows_x64.zip">HastyScribe for Windows (x64)</a> &ndash; Cross-compiled on Mac OS X Sierra (MinGW-w64 GCC 4.8.2)</li> -<li><a href="https://github.com/h3rald/hastyscribe/releases/download/v1.4.0/hastyscribe_v1.4.0_linux_x64.zip">HastyScribe for Linux (x64)</a> &ndash; Cross-compiled on Mac OS X Sierra (GNU GCC 4.8.1)</li> -<li><a href="https://github.com/h3rald/hastyscribe/releases/download/v1.4.0/hastyscribe_v1.4.0_linux_x86.zip">HastyScribe for Linux (x86)</a> &ndash; Cross-compiled on Mac OS X Sierra (GNU GCC 4.8.1)</li> -<li><a href="https://github.com/h3rald/hastyscribe/releases/download/v1.4.0/hastyscribe_v1.4.0_linux_arm.zip">HastyScribe for Linux (ARM)</a> &ndash; Cross-compiled on Mac OS X Sierra (GNU GCC 4.8.2)</li> +<li><a href="https://github.com/h3rald/hastyscribe/releases/download/v1.5.0/hastyscribe_v1.5.0_macos_x64.zip">HastyScribe for Mac OS X (x64)</a> &ndash; Compiled on Mac OS X Sierra (LLVM CLANG 8.0.0)</li> +<li><a href="https://github.com/h3rald/hastyscribe/releases/download/v1.5.0/hastyscribe_v1.5.0_windows_x64.zip">HastyScribe for Windows (x64)</a> &ndash; Cross-compiled on Mac OS X Sierra (MinGW-w64 GCC 4.8.2)</li> +<li><a href="https://github.com/h3rald/hastyscribe/releases/download/v1.5.0/hastyscribe_v1.5.0_linux_x64.zip">HastyScribe for Linux (x64)</a> &ndash; Cross-compiled on Mac OS X Sierra (GNU GCC 4.8.1)</li> +<li><a href="https://github.com/h3rald/hastyscribe/releases/download/v1.5.0/hastyscribe_v1.5.0_linux_x86.zip">HastyScribe for Linux (x86)</a> &ndash; Cross-compiled on Mac OS X Sierra (GNU GCC 4.8.1)</li> +<li><a href="https://github.com/h3rald/hastyscribe/releases/download/v1.5.0/hastyscribe_v1.5.0_linux_arm.zip">HastyScribe for Linux (ARM)</a> &ndash; Cross-compiled on Mac OS X Sierra (GNU GCC 4.8.2)</li> </ul>

@@ -336,6 +336,7 @@ <ul>

<li><span class="opt">--field/&lt;field&gt;=&lt;value&gt;</span> causes HastyScribe to set a custom field to a specific value.</li> <li><span class="opt">--notoc</span> causes HastyScribe to output HTML documents <em>without</em> automatically generating a Table of Contents at the start.</li> <li><span class="opt">--user-css=&lt;file&gt;</span> causes HastyScribe to insert the contents of the specified local file as a CSS stylesheet.</li> +<li><span class="opt">--user-js=&lt;file&gt;</span> causes HastyScribe to insert the contents of the specified local file as a Javascript script.</li> <li><span class="opt">--output-file=&lt;file&gt;</span> causes HastyScribe to write output to a local file (Use <span class="opt">--output-file=-</span> to output to standard output).</li> <li><span class="opt">--watermark=&lt;file&gt;</span> causes HastyScribe to embed and display an image as a watermark throughout the document.</li> <li><span class="opt">--fragment</span> causes HastyScribe to output just an HTML fragment instead of a full document, without embedding any image, font or stylesheet.</li>

@@ -427,7 +428,7 @@ </thead>

<tbody> <tr> <td><code>{{$timestamp}}</code> </td> -<td> 1487428968</td> +<td> 1487430039</td> </tr> <tr> <td><code>{{$date}}</code> </td>

@@ -451,19 +452,19 @@ <td> 2/18/17</td>

</tr> <tr> <td><code>{{$short-time}}</code> </td> -<td> 15:42 PM</td> +<td> 16:00 PM</td> </tr> <tr> <td><code>{{$short-time-24}}</code> </td> -<td> 15:42</td> +<td> 16:00</td> </tr> <tr> <td><code>{{$time}}</code> </td> -<td> 15:42:48 PM</td> +<td> 16:00:39 PM</td> </tr> <tr> <td><code>{{$time-24}}</code> </td> -<td> 15:42:48</td> +<td> 16:00:39</td> </tr> <tr> <td><code>{{$day}}</code> </td>

@@ -1422,4 +1423,5 @@ <p><span class="copy"></span> Fabio Cevasco &ndash; February 18, 2017</p>

<p><span>Powered by</span> <a href="https://h3rald.com/hastyscribe"><span class="hastyscribe"></span></a></p> </div> </div> + </body>
M doc/HastyScribe_UserGuide.mddoc/HastyScribe_UserGuide.md

@@ -143,6 +143,7 @@ * The following options are supported:

* [\-\-field/&lt;field&gt;=&lt;value&gt;](class:opt) causes {{hs}} to set a custom field to a specific value. * [\-\-notoc](class:opt) causes {{hs}} to output HTML documents _without_ automatically generating a Table of Contents at the start. * [\-\-user-css=&lt;file&gt;](class:opt) causes {{hs}} to insert the contents of the specified local file as a CSS stylesheet. + * [\-\-user-js=&lt;file&gt;](class:opt) causes {{hs}} to insert the contents of the specified local file as a Javascript script. * [\-\-output-file=&lt;file&gt;](class:opt) causes {{hs}} to write output to a local file (Use [\-\-output-file=-](class:opt) to output to standard output). * [\-\-watermark=&lt;file&gt;](class:opt) causes {{hs}} to embed and display an image as a watermark throughout the document. * [\-\-fragment](class:opt) causes {{hs}} to output just an HTML fragment instead of a full document, without embedding any image, font or stylesheet.
M hastyscribe.nimhastyscribe.nim

@@ -22,6 +22,7 @@ toc*: bool

input*: string output*: string css*: string + js*: string watermark*: string fragment*: bool HastyFields* = Table[string, proc():string]

@@ -87,6 +88,9 @@ proc newHastyScribe*(options: HastyOptions, fields: HastyFields): HastyScribe =

return HastyScribe(options: options, fields: initFields(fields), snippets: initTable[string, string](), macros: initTable[string, string](), document: "") # Utility Procedures + +proc style_tag*(css: string): string = + result = "<style>$1</style>" % [css] proc embed_images(hs: var HastyScribe, dir: string) = let peg_img = peg"""

@@ -255,6 +259,7 @@ # Document Variables

var main_css_tag = stylesheet.style_tag user_css_tag = "" + user_js_tag = "" watermark_css_tag = "" headings = " class=\"headings\"" author_footer = ""

@@ -283,6 +288,9 @@

if not hs.options.css.isNil: user_css_tag = hs.options.css.readFile.style_tag + if not hs.options.js.isNil: + user_js_tag = "<script type=\"text/javascript\">\n" & hs.options.js.readFile & "\n</script>" + if not hs.options.watermark.isNil: watermark_css_tag = watermark_css(hs.options.watermark)

@@ -319,8 +327,9 @@ <p>$author_footer $date</p>

<p><span>Powered by</span> <a href="https://h3rald.com/hastyscribe"><span class="hastyscribe"></span></a></p> </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] +"fonts_css_tag", embed_fonts(), "internal_css_tag", metadata.css, "watermark_css_tag", watermark_css_tag, "js", user_js_tag] hs.embed_images(dir) hs.add_jump_to_top_links() return hs.document

@@ -360,6 +369,7 @@ Options:

--field/<field>=<value> Define a new field called <field> with value <value>. --notoc Do not generate a Table of Contents. --user-css=<file> Insert contents of <file> as a CSS stylesheet. + --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.

@@ -384,6 +394,8 @@ of "notoc":

options.toc = false of "user-css": options.css = val + of "user-js": + options.js = val of "watermark": options.watermark = val of "output-file":
M hastyscribe.nimblehastyscribe.nimble

@@ -1,6 +1,6 @@

[Package] name = "hastyscribe" -version = "1.4.1" +version = "1.5.0" author = "Fabio Cevasco" description = "Self-contained markdown compiler generating self-contained HTML documents" license = "MIT"

@@ -8,4 +8,4 @@

bin = "hastyscribe" [Deps] -Requires: "nim >= 0.15.0" +Requires: "nim >= 0.16.0"