all repos — hastyscribe @ bc0fea803016736d335606e274164a845f15886d

A professional markdown compiler.

Documented Nim API; updated hastystyles.
h3rald h3rald@h3rald.com
Sun, 29 Oct 2017 19:24:19 +0100
commit

bc0fea803016736d335606e274164a845f15886d

parent

82ff5eaf590dd23a9ae682334dbd3902c62ae2cc

M build_guidebuild_guide

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

-./hastyscribe doc/HastyScribe_UserGuide.md --field/version=1.6.0 +./hastyscribe doc/HastyScribe_UserGuide.md --field/version=1.7.0
A doc/-api.md

@@ -0,0 +1,74 @@

+# Nim API + +Besides its command libe, you can also import {{hs}} as a library within your [Nim](https://nim-lang.org) program. + +## Types + +{{hs}} exposes the following Nim types: + +``` +HastyOptions* = object + toc*: bool + input*: string + output*: string + css*: string + js*: string + watermark*: string + fragment*: bool + +HastyFields* = Table[string, proc():string] + +HastySnippets* = Table[string, string] + +HastyMacros* = Table[string, string] + +HastyScribe* = object + options: HastyOptions + fields: HastyFields + snippets: HastySnippets + macros: HastyMacros + document: string +``` + +## Procs + +{{hs}} exposes the following [proc](class:kwd)s. + +### newHastyScribe + + proc newHastyScribe*(options: HastyOptions, fields: HastyFields): HastyScribe + +Instantiates a new {{hs}} object. + +### dump + + proc dump*(hs: var HastyScribe, data="all", dest=".") + +Saves linked resources to the [dest](class:dir) directory. + +[data](class:kwd) can be set to one of the following values: + +all +: Dumps all resource files. +styles +: Dumps all stylesheet files. +fonts +: Dumps all font files. + +### compileFragment + + proc compileFragment*(hs: var HastyScribe, input, dir: string, toc = false): string {.discardable.} + +Compiles the [input](class:kwd) markdown text into an HTML fragment, without embedding stylesheets or fonts. [dir](class:kwd) identifies the directory containing the input text (it is only used to resolve transclusions). + +### compileDocument + + proc compileDocument*(hs: var HastyScribe, input, dir: string): string {.discardable.} + +Compiles the [input](class:kwd) markdown text into a self-contained HTML document, embedding stylesheets and fonts. [dir](class:kwd) identifies the directory containing the input text (it is only used to resolve transclusions). + +### compile + + proc compile*(hs: var HastyScribe, input_file: string) + +Compiles the markdown file [input\_file](class:kwd) into a self-contained HTML document.
M doc/HastyScribe_UserGuide.htmdoc/HastyScribe_UserGuide.htm

@@ -2662,7 +2662,7 @@ text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);

color: #333; background-color: #f8f8f8; border: 1px solid #ccc; - white-space: pre; + white-space: pre-wrap; margin: auto; font-family: "Source Code Pro", "Monaco", "DejaVu Sans Mono", "Courier New", monospace; padding: 0;

@@ -3262,7 +3262,7 @@ text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);

color: #eee; background-color: #222; border: 1px solid #ccc; - white-space: pre; + white-space: pre-wrap; padding: 0 3px; border: 2px solid #999; border-top: 10px solid #999;

@@ -3315,7 +3315,7 @@ text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);

color: #eee; background-color: #222; border: 1px solid #ccc; - white-space: pre; + white-space: pre-wrap; padding: 0 3px; border: 2px solid #999; border-top: 10px solid #999;

@@ -4429,6 +4429,21 @@ </ul>

</li> </ul> </li> + <li><a href="#Nim-API">Nim API</a> + <ul> + <li><a href="#Types">Types</a></li> + <li><a href="#Procs">Procs</a> + <ul> + <li><a href="#newHastyScribe">newHastyScribe</a></li> + <li><a href="#dump">dump</a></li> + <li><a href="#compileFragment">compileFragment</a></li> + <li><a href="#compileDocument">compileDocument</a></li> + <li><a href="#compile">compile</a> +</li> + </ul> + </li> + </ul> + </li> <li><a href="#Credits">Credits</a></li> </ul> </li>

@@ -4546,11 +4561,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.6.0/hastyscribe_v1.6.0_macosx_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.6.0/hastyscribe_v1.6.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.6.0/hastyscribe_v1.6.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.6.0/hastyscribe_v1.6.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.6.0/hastyscribe_v1.6.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.7.0/hastyscribe_v1.7.0_macosx_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.7.0/hastyscribe_v1.7.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.7.0/hastyscribe_v1.7.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.7.0/hastyscribe_v1.7.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.7.0/hastyscribe_v1.7.0_linux_arm.zip">HastyScribe for Linux (ARM)</a> &ndash; Cross-compiled on Mac OS X Sierra (GNU GCC 4.8.2)</li> </ul>

@@ -4603,6 +4618,7 @@ <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> +<li><span class="opt">--dump=all|styles|fonts</span> causes HastyScribe to dump all resources/stylesheets/fonts to the current directory.</li> </ul> </li> </ul>

@@ -4706,59 +4722,59 @@ </thead>

<tbody> <tr> <td><code>{{$timestamp}}</code> </td> -<td> 1506543210</td> +<td> 1509301438</td> </tr> <tr> <td><code>{{$date}}</code> </td> -<td> 2017-09-27</td> +<td> 2017-10-29</td> </tr> <tr> <td><code>{{$full-date}}</code> </td> -<td> Wednesday, September 27, 2017</td> +<td> Sunday, October 29, 2017</td> </tr> <tr> <td><code>{{$long-date}}</code> </td> -<td> September 27, 2017</td> +<td> October 29, 2017</td> </tr> <tr> <td><code>{{$medium-date}}</code> </td> -<td> Sep 27, 2017</td> +<td> Oct 29, 2017</td> </tr> <tr> <td><code>{{$short-date}}</code> </td> -<td> 9/27/17</td> +<td> 10/29/17</td> </tr> <tr> <td><code>{{$short-time}}</code> </td> -<td> 20:13 PM</td> +<td> 19:23 PM</td> </tr> <tr> <td><code>{{$short-time-24}}</code> </td> -<td> 20:13</td> +<td> 19:23</td> </tr> <tr> <td><code>{{$time}}</code> </td> -<td> 20:13:30 PM</td> +<td> 19:23:58 PM</td> </tr> <tr> <td><code>{{$time-24}}</code> </td> -<td> 20:13:30</td> +<td> 19:23:58</td> </tr> <tr> <td><code>{{$day}}</code> </td> -<td> 27</td> +<td> 29</td> </tr> <tr> <td><code>{{$short-day}}</code> </td> -<td> 27</td> +<td> 29</td> </tr> <tr> <td><code>{{$month}}</code> </td> -<td> 09</td> +<td> 10</td> </tr> <tr> <td><code>{{$short-month}}</code> </td> -<td> 9</td> +<td> 10</td> </tr> <tr> <td><code>{{$year}}</code> </td>

@@ -4770,23 +4786,23 @@ <td> 17</td>

</tr> <tr> <td><code>{{$weekday}}</code> </td> -<td> Wednesday</td> +<td> Sunday</td> </tr> <tr> <td><code>{{$weekday-abbr}}</code> </td> -<td> 27</td> +<td> 29</td> </tr> <tr> <td><code>{{$month-name}}</code> </td> -<td> September</td> +<td> October</td> </tr> <tr> <td><code>{{$month-name-abbr}}</code> </td> -<td> Sep</td> +<td> Oct</td> </tr> <tr> <td><code>{{$timezone-offset}}</code> </td> -<td> +00:00</td> +<td> +01:00</td> </tr> </tbody> </table>

@@ -5673,6 +5689,95 @@ <p>Produces the following output:</p>

<div class="terminal-su"><p>shutdown -h now</p></div> +<a name="Nim-API"></a> +<h2>Nim API<a href="#document-top" title="Go to top"></a></h2> + +<p>Besides its command libe, you can also import HastyScribe as a library within your <a href="https://nim-lang.org">Nim</a> program.</p> + +<a name="Types"></a> +<h3>Types<a href="#document-top" title="Go to top"></a></h3> + +<p>HastyScribe exposes the following Nim types:</p> + +<pre><code>HastyOptions* = object + toc*: bool + input*: string + output*: string + css*: string + js*: string + watermark*: string + fragment*: bool + +HastyFields* = Table[string, proc():string] + +HastySnippets* = Table[string, string] + +HastyMacros* = Table[string, string] + +HastyScribe* = object + options: HastyOptions + fields: HastyFields + snippets: HastySnippets + macros: HastyMacros + document: string +</code></pre> + +<a name="Procs"></a> +<h3>Procs<a href="#document-top" title="Go to top"></a></h3> + +<p>HastyScribe exposes the following <span class="kwd">proc</span>s.</p> + +<a name="newHastyScribe"></a> +<h4>newHastyScribe<a href="#document-top" title="Go to top"></a></h4> + +<pre><code> proc newHastyScribe*(options: HastyOptions, fields: HastyFields): HastyScribe +</code></pre> + +<p>Instantiates a new HastyScribe object.</p> + +<a name="dump"></a> +<h4>dump<a href="#document-top" title="Go to top"></a></h4> + +<pre><code> proc dump*(hs: var HastyScribe, data="all", dest=".") +</code></pre> + +<p>Saves linked resources to the <span class="dir">dest</span> directory.</p> + +<p><span class="kwd">data</span> can be set to one of the following values:</p> + +<dl> +<dt>all</dt> +<dd>Dumps all resource files.</dd> +<dt>styles</dt> +<dd>Dumps all stylesheet files.</dd> +<dt>fonts</dt> +<dd>Dumps all font files.</dd> +</dl> + +<a name="compileFragment"></a> +<h4>compileFragment<a href="#document-top" title="Go to top"></a></h4> + +<pre><code> proc compileFragment*(hs: var HastyScribe, input, dir: string, toc = false): string {.discardable.} +</code></pre> + +<p>Compiles the <span class="kwd">input</span> markdown text into an HTML fragment, without embedding stylesheets or fonts. <span class="kwd">dir</span> identifies the directory containing the input text (it is only used to resolve transclusions).</p> + +<a name="compileDocument"></a> +<h4>compileDocument<a href="#document-top" title="Go to top"></a></h4> + +<pre><code> proc compileDocument*(hs: var HastyScribe, input, dir: string): string {.discardable.} +</code></pre> + +<p>Compiles the <span class="kwd">input</span> markdown text into a self-contained HTML document, embedding stylesheets and fonts. <span class="kwd">dir</span> identifies the directory containing the input text (it is only used to resolve transclusions).</p> + +<a name="compile"></a> +<h4>compile<a href="#document-top" title="Go to top"></a></h4> + +<pre><code> proc compile*(hs: var HastyScribe, input_file: string) +</code></pre> + +<p>Compiles the markdown file <span class="kwd">input_file</span> into a self-contained HTML document.</p> + <a name="Credits"></a> <h2>Credits<a href="#document-top" title="Go to top"></a></h2>

@@ -5698,7 +5803,7 @@

<p style="text-align:center;"> <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAAAfCAYAAABjyArgAAAGa0lEQVRo3u1aW08bRxTmuSqIV0SlIFWtAKkVtEpfWiVI6Q+gT60qpeIhTXkrSpqoaZ1AkJMobSRkkUahEtAWCVWBYMDcfME22MZ3rw0hrzzwAxC/4FTfrGeYXXa9u8Y0yGGkEeu5nGW+OfOdy2wDETU1NDTQea19JcKf8o/lwBKthlbIH16j0EaQwrEwbSSiFEvFaCuToFQuSel8mrKFDOWULOWKObUqWcoqGcrk02wMxsZTMT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8/nRx2yEfGBihJlly0YDdacIuRyeHhIE+Pj7Bmaqz/i4On/hSKQT9jeLYkFyVrIjVVbWxsjcwCOZxx/3sc9DQDO+4xoAmF1TsPDQers7DQ1Kmbaa9c4QVMBBLQXldMEDN29X110ofU9W3KuX7tmWG0bOfi+yCvwBQFE/SKNONkOX8snAO+AT7yV2RIAD96/J9wiuwBbuVcyPbjvDws3DS4btNqpnBO7aW8SYAQc3FWzE2hwrnMSIDz57fdjgUY1cipxb8VAwy5FwPDBdcMzQJUpQt9nlyIA8PSL6foOlSsZuUqGzI6R4zusGrkie5ds5ADwUsBHU/9OabJW2DTIwXw5aLFK0gAcOUnzJuUcc9N4iAzXSn/Mzdw0gMzb9X0o0GjZTUtLblogEhCZNZYfXpqjX+7WYbqSBxpymKz3Z2sZaGyWAw2kLnlWjact6+l2QwCcSBuHyk7i8WpDZTn5XrcAy8meib/Ga5/sGfUw2Uj24F08ZSkn3vnNRj1dHQmAUV2DLpGuvPrdVQ3ITpI+0HrDdGUhQ8MPht/G2+WjHwM3fmRuVLGKhDv6MEZOuF/87CKjBvjZrnLe960GGBUJcAQDAFnW5GqujABuvpijZ2PP7H5HYBhk6MfYkWP22yyZ5EROpaSUJcACZEW99AQnO770HOWXnlnb4BoBYbQwJxtVab7djaqBHOMO0IV8bQ/QrK7tcXPBru3xfUQh45gWrNKVTjfK7G8t5VQNMLvf+rSbvIte5sLBT1bEhycl6cOTEmuTPzyZ93np0uVL1XxqdCJqsKKEajS4BnKs/2GA9fjJYwpFQ9KnU+WKT6cKGdaHMdUAe1oafGY5+LzWsBLRO+dAnN7Xlf8BOGLNYHeHmZwAAAAASUVORK5CYII=" alt="Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Unported License" /></p> </div> <div id="footer"> - <p><span class="copy"></span> Fabio Cevasco &ndash; September 27, 2017</p> + <p><span class="copy"></span> Fabio Cevasco &ndash; October 29, 2017</p> <p><span>Powered by</span> <a href="https://h3rald.com/hastyscribe"><span class="hastyscribe"></span></a></p> </div> </div>
M doc/HastyScribe_UserGuide.mddoc/HastyScribe_UserGuide.md

@@ -6,4 +6,5 @@ {@ -overview.md || 1 @}

{@ -getting-started.md || 1 @} {@ -usage.md || 1 @} {@ -syntax.md || 1 @} +{@ -api.md || 1 @} {@ -credits.md || 1 @}
M hastyscribe.nimhastyscribe.nim

@@ -283,10 +283,10 @@ result = hs.parse_macros(result)

# Public API -proc dump*(hs: var HastyScribe, item="all", dest=".") = - if item == "all" or item == "styles": +proc dump*(hs: var HastyScribe, data="all", dest=".") = + if data == "all" or data == "styles": (dest/"hastyscribe.css").writeFile(stylesheet) - if item == "all" or item == "fonts": + if data == "all" or data == "fonts": (dest/"SourceCodePro-Regular.ttf.woff").writeFile(sourcecodepro_font) (dest/"SourceSansPro-Regular.ttf.woff").writeFile(sourcesanspro_font) (dest/"SourceSansPro-Bold.ttf.woff").writeFile(sourcesanspro_bold_font)
M hastyscribe.nimblehastyscribe.nimble

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

[Package] name = "hastyscribe" -version = "1.6.0" +version = "1.7.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.16.0" +Requires: "nim >= 0.17.2"
M lib/consts.nimlib/consts.nim

@@ -3,11 +3,11 @@ const

stylesheet* = "../packages/hastystyles/styles/hastyscribe.css".slurp hastyscribe_font* = "../packages/hastystyles/fonts/hastyscribe.woff".slurp fontawesome_font* = "../packages/hastystyles/fonts/fontawesome-webfont.woff".slurp - sourcecodepro_font* = "../packages/hastystyles/fonts/SourceCodePro-Regular.ttf.woff".slurp - sourcesanspro_font* = "../packages/hastystyles/fonts/SourceSansPro-Regular.ttf.woff".slurp - sourcesanspro_bold_font* = "../packages/hastystyles/fonts/SourceSansPro-Bold.ttf.woff".slurp - sourcesanspro_it_font* = "../packages/hastystyles/fonts/SourceSansPro-It.ttf.woff".slurp - sourcesanspro_boldit_font* = "../packages/hastystyles/fonts/SourceSansPro-BoldIt.ttf.woff".slurp + sourcecodepro_font* = "../packages/hastystyles/fonts/SourceCodePro-Regular.woff".slurp + sourcesanspro_font* = "../packages/hastystyles/fonts/SourceSansPro-Regular.woff".slurp + sourcesanspro_bold_font* = "../packages/hastystyles/fonts/SourceSansPro-Bold.woff".slurp + sourcesanspro_it_font* = "../packages/hastystyles/fonts/SourceSansPro-It.woff".slurp + sourcesanspro_boldit_font* = "../packages/hastystyles/fonts/SourceSansPro-BoldIt.woff".slurp watermark_style* = """ #container { position: relative;