all repos — hastyscribe @ 67ce5735917a52024ec92c71f85d7a90abe04284

A professional markdown compiler.

Merge pull request #78 from tomidery/fix-gcsafe

Fabio Cevasco h3rald@h3rald.com
Tue, 06 Apr 2021 22:20:57 +0200
commit

67ce5735917a52024ec92c71f85d7a90abe04284

parent

8ac9afc750354133311c4020209f8c377187e073

M README.mdREADME.md

@@ -23,6 +23,7 @@ * **\-\-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. * **\-\-dump=all|styles|fonts** causes HastyScribe to dump all resources/stylesheets/fonts to the current directory. + * **\-\-help** causes HastyScribe to display the usage information and quit. ## FAQs
M doc/-usage.mddoc/-usage.md

@@ -18,6 +18,7 @@ * [\-\-output-file=<file>](class:opt) causes {{hs}} to write output to a local file (Use [\-\-output-file=-](class:opt) to output to standard output).

* [\-\-watermark=<file>](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. * [\-\-dump=all|styles|fonts](class:opt) causes {{hs}} to dump all resources/stylesheets/fonts to the current directory. + * [\-\-help](class:opt) causes {{hs}} to display the usage information and quit. ## Linux/OSX Examples
M doc/HastyScribe_UserGuide.htmdoc/HastyScribe_UserGuide.htm

@@ -7451,9 +7451,9 @@

<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.12.3/hastyscribe_v1.12.3_macosx_x64.zip">HastyScribe for Mac OS X (x64)</a></li> -<li><a href="https://github.com/h3rald/hastyscribe/releases/download/v1.12.3/hastyscribe_v1.12.3_windows_x64.zip">HastyScribe for Windows (x64)</a></li> -<li><a href="https://github.com/h3rald/hastyscribe/releases/download/v1.12.3/hastyscribe_v1.12.3_linux_x64.zip">HastyScribe for Linux (x64)</a></li> +<li><a href="https://github.com/h3rald/hastyscribe/releases/download/v1.12.4/hastyscribe_v1.12.4_macosx_x64.zip">HastyScribe for Mac OS X (x64)</a></li> +<li><a href="https://github.com/h3rald/hastyscribe/releases/download/v1.12.4/hastyscribe_v1.12.4_windows_x64.zip">HastyScribe for Windows (x64)</a></li> +<li><a href="https://github.com/h3rald/hastyscribe/releases/download/v1.12.4/hastyscribe_v1.12.4_linux_x64.zip">HastyScribe for Linux (x64)</a></li> </ul>

@@ -7507,6 +7507,7 @@ <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> +<li><span class="opt">--help</span> causes HastyScribe to display the usage information and quit.</li> </ul> </li> </ul>

@@ -7610,87 +7611,87 @@ </thead>

<tbody> <tr> <td><code>{{$timestamp}}</code> </td> -<td> 1604580919</td> +<td> 1617135534</td> </tr> <tr> <td><code>{{$date}}</code> </td> -<td> 2020-11-05</td> +<td> 2021-03-30</td> </tr> <tr> <td><code>{{$full-date}}</code> </td> -<td> Thursday, November 5, 2020</td> +<td> Tuesday, March 30, 2021</td> </tr> <tr> <td><code>{{$long-date}}</code> </td> -<td> November 5, 2020</td> +<td> March 30, 2021</td> </tr> <tr> <td><code>{{$medium-date}}</code> </td> -<td> Nov 5, 2020</td> +<td> Mar 30, 2021</td> </tr> <tr> <td><code>{{$short-date}}</code> </td> -<td> 11/5/20</td> +<td> 3/30/21</td> </tr> <tr> <td><code>{{$short-time}}</code> </td> -<td> 13:55 PM</td> +<td> 22:18 PM</td> </tr> <tr> <td><code>{{$short-time-24}}</code> </td> -<td> 13:55</td> +<td> 22:18</td> </tr> <tr> <td><code>{{$time}}</code> </td> -<td> 13:55:19 PM</td> +<td> 22:18:54 PM</td> </tr> <tr> <td><code>{{$time-24}}</code> </td> -<td> 13:55:19</td> +<td> 22:18:54</td> </tr> <tr> <td><code>{{$day}}</code> </td> -<td> 05</td> +<td> 30</td> </tr> <tr> <td><code>{{$short-day}}</code> </td> -<td> 5</td> +<td> 30</td> </tr> <tr> <td><code>{{$month}}</code> </td> -<td> 11</td> +<td> 03</td> </tr> <tr> <td><code>{{$short-month}}</code> </td> -<td> 11</td> +<td> 3</td> </tr> <tr> <td><code>{{$year}}</code> </td> -<td> 2020</td> +<td> 2021</td> </tr> <tr> <td><code>{{$short-year}}</code> </td> -<td> 20</td> +<td> 21</td> </tr> <tr> <td><code>{{$weekday}}</code> </td> -<td> Thursday</td> +<td> Tuesday</td> </tr> <tr> <td><code>{{$weekday-abbr}}</code> </td> -<td> 05</td> +<td> 30</td> </tr> <tr> <td><code>{{$month-name}}</code> </td> -<td> November</td> +<td> March</td> </tr> <tr> <td><code>{{$month-name-abbr}}</code> </td> -<td> Nov</td> +<td> Mar</td> </tr> <tr> <td><code>{{$timezone-offset}}</code> </td> -<td> +01:00</td> +<td> +02:00</td> </tr> </tbody> </table>

@@ -8827,7 +8828,7 @@

<p style="text-align:center;"> <span class="fa-creative-commons"></span> <span class="fa-creative-commons-by"></span> <span class="fa-creative-commons-nc"></span> <span class="fa-creative-commons-nd"></span></p> </div> <div id="footer"> - <p><span class="copy"></span> Fabio Cevasco &ndash; November 5, 2020</p> + <p><span class="copy"></span> Fabio Cevasco &ndash; March 30, 2021</p> <p><span>Powered by</span> <a href="https://h3rald.com/hastyscribe"><span class="hastyscribe"></span></a></p> </div> </div>
M src/hastyscribe.nimsrc/hastyscribe.nim

@@ -49,7 +49,7 @@ css*: string

js*: string watermark*: string fragment*: bool - HastyFields* = Table[string, proc():string] + HastyFields* = Table[string, string] HastySnippets* = Table[string, string] HastyMacros* = Table[string, string] HastyScribe* = object

@@ -63,52 +63,31 @@ if logging.getHandlers().len == 0:

newNiftyLogger().addHandler() proc initFields(fields: HastyFields): HastyFields {.gcsafe.} = - result = initTable[string, proc():string]() + result = initTable[string, string]() for key, value in fields.pairs: result[key] = value var now = getTime().local() - result["timestamp"] = proc():string = - return $now.toTime.toUnix().int - result["date"] = proc():string = - return now.format("yyyy-MM-dd") - result["full-date"] = proc():string = - return now.format("dddd, MMMM d, yyyy") - result["long-date"] = proc():string = - return now.format("MMMM d, yyyy") - result["medium-date"] = proc():string = - return now.format("MMM d, yyyy") - result["short-date"] = proc():string = - return now.format("M/d/yy") - result["short-time-24"] = proc():string = - return now.format("HH:mm") - result["short-time"] = proc():string = - return now.format("HH:mm tt") - result["time-24"] = proc():string = - return now.format("HH:mm:ss") - result["time"] = proc():string = - return now.format("HH:mm:ss tt") - result["day"] = proc():string = - return now.format("dd") - result["month"] = proc():string = - return now.format("MM") - result["year"] = proc():string = - return now.format("yyyy") - result["short-day"] = proc():string = - return now.format("d") - result["short-month"] = proc():string = - return now.format("M") - result["short-year"] = proc():string = - return now.format("yy") - result["weekday"] = proc():string = - return now.format("dddd") - result["weekday-abbr"] = proc():string = - return now.format("dd") - result["month-name"] = proc():string = - return now.format("MMMM") - result["month-name-abbr"] = proc():string = - return now.format("MMM") - result["timezone-offset"] = proc():string = - return now.format("zzz") + result["timestamp"] = $now.toTime.toUnix().int + result["date"] = now.format("yyyy-MM-dd") + result["full-date"] = now.format("dddd, MMMM d, yyyy") + result["long-date"] = now.format("MMMM d, yyyy") + result["medium-date"] = now.format("MMM d, yyyy") + result["short-date"] = now.format("M/d/yy") + result["short-time-24"] = now.format("HH:mm") + result["short-time"] = now.format("HH:mm tt") + result["time-24"] = now.format("HH:mm:ss") + result["time"] = now.format("HH:mm:ss tt") + result["day"] = now.format("dd") + result["month"] = now.format("MM") + result["year"] = now.format("yyyy") + result["short-day"] = now.format("d") + result["short-month"] = now.format("M") + result["short-year"] = now.format("yy") + result["weekday"] = now.format("dddd") + result["weekday-abbr"] = now.format("dd") + result["month-name"] = now.format("MMMM") + result["month-name-abbr"] = now.format("MMM") + result["timezone-offset"] = now.format("zzz") proc newHastyScribe*(options: HastyOptions, fields: HastyFields): HastyScribe = return HastyScribe(options: options, fields: initFields(fields), snippets: initTable[string, string](), macros: initTable[string, string](), document: "")

@@ -281,7 +260,7 @@ var matches:array[0..0, string]

discard field.match(peg_field, matches) var id = matches[0].strip if hs.fields.hasKey(id): - result = result.replace(field, hs.fields[id]()) + result = result.replace(field, hs.fields[id]) else: warn "Field '" & id & "' not defined." result = result.replace(field, "")

@@ -509,13 +488,14 @@ (Use "--output-file=-" to output to stdout)

--watermark=<file> Use the image in <file> as a watermark. --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.""" + --dump=all|styles|fonts Dumps all resources/stylesheets/fonts to the current directory. + --help Display the usage information.""" var input = "" var files = newSeq[string](0) var options = HastyOptions(toc: true, output: "", css: "", watermark: "", fragment: false) - var fields = initTable[string, proc():string]() + var fields = initTable[string, string]() var dumpdata = "" # Parse Parameters

@@ -543,11 +523,13 @@ of "output-file":

options.output = val of "fragment": options.fragment = true + of "help": + echo usage + quit(1) else: if key.startsWith("field/"): let val = val - fields[key.replace("field/", "")] = proc(): string = - return val + fields[key.replace("field/", "")] = val discard else: discard
M src/hastyscribepkg/config.nimsrc/hastyscribepkg/config.nim

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

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