Released HastyScribe v1.0.9.
h3rald h3rald@h3rald.com
Fri, 02 Jan 2015 21:34:48 +0100
3 files changed,
29 insertions(+),
42 deletions(-)
M
content/articles/hastyscribe.md
→
content/articles/hastyscribe.md
@@ -46,20 +46,20 @@ ### The Ingredients
The first I decided was _not_ to create a GUI for this program. I wanted a command-line utility, and I wanted it to be also self-contained and cross-platform. I am a big fan of [Fossil](http://www.fossil-scm.org/index.html/doc/tip/www/index.wiki) and [SQLite](http://www.sqlite.org/), and I wanted my utility to be tiny, have no dependencies, and run on both my Mac and my Windows computers (and on Linux of course, why not!). -#### Nimrod Programming Language +#### Nim Programming Language -So I picked a programming language suitable to the task. The winner was [Nimrod](http://nimrod-lang.org/), because: +So I picked a programming language suitable to the task. The winner was [Nim](http://nim-lang.org/), because: * It is very elegant and very expressive, like a high-level programming language * It generates C code that can be compiled on many platforms * It produces very small executables * It can work with existing C libraries * My C is more than a bit rusty, but yes, someone else could have used C for this - * I really, really wanted to try building something with Nimrod + * I really, really wanted to try building something with Nim #### Discount Markdown Library -Then I went shopping for a Markdown library. At the time there weren't any in Nimrod, so I went looking for one implemented in C that I could use with Nimrod. I chose [Discount](http://www.pell.portland.or.us/~orc/Code/discount/) because of the unique features it offered compared to the competition, especially two of them: +Then I went shopping for a Markdown library. At the time there weren't any in Nim, so I went looking for one implemented in C that I could use with Nim. I chose [Discount](http://www.pell.portland.or.us/~orc/Code/discount/) because of the unique features it offered compared to the competition, especially two of them: * Pseudo-protocols, e.g.: `[some text](class:some-class)` – useful to add a class to an inline element) * Class blocks: <q>A blockquote with a first line of `> %class%` will become `<div class="class">` instead of a `<blockquote>`.</q>@@ -80,7 +80,7 @@ [fa]:http://fortawesome.github.io/Font-Awesome/
### Developing HastyScribe -The first thing to do was to make Discount work with Nimrod. It turned out to be relatively easy to do, because the Nimrod compiler calls a C compiler (clang or gcc, typically) after compiling Nimrod code to C, and the compiler call can be configured to link static C libraries to produce a single executable file. Just what I wanted. +The first thing to do was to make Discount work with Nim. It turned out to be relatively easy to do, because the Nim compiler calls a C compiler (clang or gcc, typically) after compiling Nim code to C, and the compiler call can be configured to link static C libraries to produce a single executable file. Just what I wanted. #### Compiling Discount@@ -99,7 +99,7 @@ <pre><code class="c">typedef @DWORD@ mkd_flag_t;
typedef unsigned long DWORD; typedef DWORD mkd_flag_t;</code></pre> -There's probably a better way to go about this, but it did the trick and I got my **libmarkdown.a** both on Windows and then on Mac. I do have a Ubuntu machine at home but I hardly use it nowadays (I am normally happy with just my [Raspberry Pi](http://www.raspberrypi.org/) running Arch Linux ARM – but Nimrod doesn't run on ARM as far as I know). +There's probably a better way to go about this, but it did the trick and I got my **libmarkdown.a** both on Windows and then on Mac. I do have a Ubuntu machine at home but I hardly use it nowadays (I am normally happy with just my [Raspberry Pi](http://www.raspberrypi.org/) running Arch Linux ARM – but Nim doesn't run on ARM as far as I know). #### markdown.nim@@ -109,9 +109,9 @@ * compile Markdown code into an HTML fragment
* generate a Table of Contents automatically * parse the Pandoc-style document headers (title, author, date) supported by Discount - So I armed myself with [c2nim](https://github.com/h3rald/hastyscribe/blob/master/hastyscribe.nim) a handy little utility that can be used to convert C code into Nimrod. In practice, it is very handy for converting simple things like .h files, so I tried it on **markdown.h**. + So I armed myself with [c2nim](https://github.com/h3rald/hastyscribe/blob/master/hastyscribe.nim) a handy little utility that can be used to convert C code into Nim. In practice, it is very handy for converting simple things like .h files, so I tried it on **markdown.h**. - Didn't work in a totally automatic way, but it got me far enough that I could handle fixing the remaining bits, mostly consisting in name clashes due to Nimrod's rather unusual case-and-underscore-unsensitiveness and in a few pragmas to add here and there (`{.push importc, cdecl.}` at the start, for example). + Didn't work in a totally automatic way, but it got me far enough that I could handle fixing the remaining bits, mostly consisting in name clashes due to Nim's rather unusual case-and-underscore-unsensitiveness and in a few pragmas to add here and there (`{.push importc, cdecl.}` at the start, for example). I also added two high level `md` functions that basically can generate an HTML document with or without document headers. Here's one of them:@@ -149,24 +149,24 @@ result = cstringArrayToSeq(res)[0]
mkd_cleanup(mmiot) return -Anyhow, I managed to create a working [markdown.nim](https://github.com/h3rald/hastyscribe/blob/master/markdown.nim) that can be used as any other Nimrod library (provided that libmarkdown.a is available at compilation time). +Anyhow, I managed to create a working [markdown.nim](https://github.com/h3rald/hastyscribe/blob/master/markdown.nim) that can be used as any other Nim library (provided that libmarkdown.a is available at compilation time). #### hastyscribe.nim Writing the code for HastyScribe itself wasn't too hard (Discount does all the heavy-lifting, let's be honest). -At the beginning of [hastyscribe.nim](https://github.com/h3rald/hastyscribe/blob/master/hastyscribe.nim) you'll find a few `slurp`s – that yummy Nimrod proc is what's needed to physically embed all the assets in the executable, and that's why HastyScribe does not need any stylesheets or fonts lying around. +At the beginning of [hastyscribe.nim](https://github.com/h3rald/hastyscribe/blob/master/hastyscribe.nim) you'll find a few `slurp`s – that yummy Nim proc is what's needed to physically embed all the assets in the executable, and that's why HastyScribe does not need any stylesheets or fonts lying around. -For the implementation of the snippet functionality and for converting fonts and images into base64 to create the data URIs I used Nimrod's [pegs](http://nimrod-lang.org/pegs.html) module. I chose this module simply because the [regular expression](http://nimrod-lang.org/re.html) module is an _impure_ (as in "not completely Nimrod code") module and requires PCRE as a dynamic library and... well, yes, it's the same self-contained obsession thing again, you guessed right. +For the implementation of the snippet functionality and for converting fonts and images into base64 to create the data URIs I used Nim's [pegs](http://nim-lang.org/pegs.html) module. I chose this module simply because the [regular expression](http://nim-lang.org/re.html) module is an _impure_ (as in "not completely Nim code") module and requires PCRE as a dynamic library and... well, yes, it's the same self-contained obsession thing again, you guessed right. Anyhow, the pegs module did a great job with the snippet and image tag parsing. I didn't really even try to integrate this extra parsing within the Markdown code parsing done by Discount, and... well OK, I currently do two separate parsing passes: one before parsing Markdown, to parse snippets, which can therefore contain Markdown code, and another one after the Markdown code has been converted to HTML, to replace standard image (relative) URLs with data URIs (no, I don't auto-download and convert remotely-hosted images... not yet anyway, so patches are welcome!). #### The stylesheet! -Honestly, the Nimrod coding part wasn't the longest part of the development phase. If you look at the code stats on Github for the [HastyScribe](https://github.com/h3rald/hastyscribe) repository, it breaks down to the following: +Honestly, the Nim coding part wasn't the longest part of the development phase. If you look at the code stats on Github for the [HastyScribe](https://github.com/h3rald/hastyscribe) repository, it breaks down to the following: * Shell: 0.2% - * Nimrod: 17.1% + * Nim: 17.1% * CSS: 82.7% Yep. Most of the code is CSS ([LESS](http://lesscss.org/) actually), and it did take a while to get it right. I used [normalize.css](http://necolas.github.io/normalize.css/) to start with, and I used part of the [FontAwesome][fa] LESS sources as well for the icon classes. The rest is all mine – but I did look for inspiration in GitHub's own stylesheet for the layout of notes and sidebars.@@ -184,16 +184,3 @@
An example document? Sure, here's the official [HastyScribe User Guide](/hastyscribe/HastyScribe_UserGuide.htm) (and here's the corresponding [source file](https://raw.githubusercontent.com/h3rald/hastyscribe/master/doc/HastyScribe_UserGuide.md)). If you're interested in giving HastyScribe a try, head over to the [project page](/hastyscribe/) and grab it. The pre-compiled binaries are only for Windows and Mac, but I think Linux/BSD/\*nix enthusiasts won't have any trouble compiling Discount and HastyScribe from source anyway! - - - - - - - - - - - - -
M
content/hastyscribe.erb
→
content/hastyscribe.erb
@@ -7,10 +7,10 @@ type: project
github: hastyscribe links: - "User Guide": /hastyscribe/HastyScribe_UserGuide.htm -- "Download": https://github.com/h3rald/hastyscribe/releases/v1.0.8 +- "Download": https://github.com/h3rald/hastyscribe/releases/v1.0.9 - "Source": https://github.com/h3rald/hastyscribe status: Active -version: 1.0.8 +version: 1.0.9 ----- <div class="jumbotron">@@ -80,22 +80,22 @@ <i class="fa fa-download"></i> Download <span class="caret"></span>
</button> <ul class="dropdown-menu" role="menu" style="text-align: left;"> <li> - <a href="https://github.com/h3rald/hastyscribe/releases/download/v1.0.8/hastyscribe_v1.0.8_macosx_x86.zip"> + <a href="https://github.com/h3rald/hastyscribe/releases/download/v1.0.9/hastyscribe_v1.0.9_macosx_x86.zip"> <i class="fa fa-apple"></i> HastyScribe for OS X (x86) </a> </li> <li> - <a href="https://github.com/h3rald/hastyscribe/releases/download/v1.0.8/hastyscribe_v1.0.8_linux_x86.zip"> + <a href="https://github.com/h3rald/hastyscribe/releases/download/v1.0.9/hastyscribe_v1.0.9_linux_x86.zip"> <i class="fa fa-linux"></i> HastyScribe for Linux (x86) </a> </li> <li> - <a href="https://github.com/h3rald/hastyscribe/releases/download/v1.0.8/hastyscribe_v1.0.8_linux_arm.zip"> + <a href="https://github.com/h3rald/hastyscribe/releases/download/v1.0.9/hastyscribe_v1.0.9_linux_arm.zip"> <i class="fa fa-linux"></i> HastyScribe for Linux (ARM) </a> </li> <li> - <a href="https://github.com/h3rald/hastyscribe/releases/download/v1.0.8/hastyscribe_v1.0.8_windows_x86.zip"> + <a href="https://github.com/h3rald/hastyscribe/releases/download/v1.0.9/hastyscribe_v1.0.9_windows_x86.zip"> <i class="fa fa-windows"></i> HastyScribe for Windows (x86) </a> </li>
M
content/hastyscribe/HastyScribe_UserGuide.htm
→
content/hastyscribe/HastyScribe_UserGuide.htm
@@ -234,19 +234,19 @@ <h2 id="Getting.Started">Getting Started<a href="#document-top" title="Go to top"></a></h2>
<h3 id="Downloading.Pre-built.Binaries">Downloading Pre-built Binaries<a href="#document-top" title="Go to top"></a></h3> -<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/v1.0.8">Github Release Page</a>:</p> +<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/v1.0.9">Github Release Page</a>:</p> <ul> -<li><a href="https://github.com/h3rald/hastyscribe/releases/download/v1.0.8/hastyscribe_v1.0.8_macosx_x86.zip">HastyScribe for Mac OS X (x86)</a> – Compiled on OS X Mavericks (LLVM CLANG 6.0)</li> -<li><a href="https://github.com/h3rald/hastyscribe/releases/download/v1.0.8/hastyscribe_v1.0.8_windows_x86.zip">HastyScribe for Windows (x86)</a> – Cross-compiled on OS X Mavericks (MinGW GCC 4.8.0)</li> -<li><a href="https://github.com/h3rald/hastyscribe/releases/download/v1.0.8/hastyscribe_v1.0.8_linux_x86.zip">HastyScribe for Linux (x86)</a> – Cross-compiled on OS X Mavericks (GNU GCC 4.8.1)</li> -<li><a href="https://github.com/h3rald/hastyscribe/releases/download/v1.0.8/hastyscribe_v1.0.8_linux_arm.zip">HastyScribe for Linux (ARM)</a> – Cross-compiled on OS X Mavericks (GNU GCC 4.8.2)</li> +<li><a href="https://github.com/h3rald/hastyscribe/releases/download/v1.0.9/hastyscribe_v1.0.9_macosx_x86.zip">HastyScribe for Mac OS X (x86)</a> – Compiled on OS X Mavericks (LLVM CLANG 6.0)</li> +<li><a href="https://github.com/h3rald/hastyscribe/releases/download/v1.0.9/hastyscribe_v1.0.9_windows_x86.zip">HastyScribe for Windows (x86)</a> – Cross-compiled on OS X Mavericks (MinGW GCC 4.8.0)</li> +<li><a href="https://github.com/h3rald/hastyscribe/releases/download/v1.0.9/hastyscribe_v1.0.9_linux_x86.zip">HastyScribe for Linux (x86)</a> – Cross-compiled on OS X Mavericks (GNU GCC 4.8.1)</li> +<li><a href="https://github.com/h3rald/hastyscribe/releases/download/v1.0.9/hastyscribe_v1.0.9_linux_arm.zip">HastyScribe for Linux (ARM)</a> – Cross-compiled on OS X Mavericks (GNU GCC 4.8.2)</li> </ul> <h3 id="Installing.using.Nimble">Installing using Nimble<a href="#document-top" title="Go to top"></a></h3> -<p>If you already have <a href="http://nimrod-code.org/">Nimrod</a> installed on your computer, you can simply run</p> +<p>If you already have <a href="http://nim-lang.org/">Nim</a> installed on your computer, you can simply run</p> <p><span class="cmd">nimble install hastyscribe</span></p>@@ -275,10 +275,10 @@
<p>Once you have a <span class="file">libmarkdown.a</span> static library for your platform:</p> <ol> -<li>Download and install <a href="http://nimrod-code.org/">Nimrod</a>.</li> +<li>Download and install <a href="http://nim-lang.org/">Nim</a>.</li> <li>Clone the HastyScribe <a href="https://github.com/h3rald/hastyscribe">repository</a>.</li> <li>Put your <span class="file">libmarkdown.a</span> file in the <span class="dir">vendor</span> directory.</li> -<li>Run <span class="cmd">nimrod c hastyscribe.nim</span></li> +<li>Run <span class="cmd">nim c hastyscribe.nim</span></li> </ol>@@ -1104,13 +1104,13 @@
<p>Special thanks to:</p> <ul> -<li>Andreas Rumpf, creator of the amazing <a href="http://nimrod-code.org/">Nimrod</a> programming language, used to implement HastyScribe.</li> +<li>Andreas Rumpf, creator of the amazing <a href="http://nim-lang.org/">Nim</a> programming language, used to implement HastyScribe.</li> <li>Ethan Lai, developer of the handy <a href="http://koala-app.com/">Koala</a> app, used to compile all the LESS code into CSS.</li> </ul> </div> <div id="footer"> - <p><span class="copy"></span> Fabio Cevasco – December 26, 2014</p> + <p><span class="copy"></span> Fabio Cevasco – January 2, 2015</p> <p><span>Powered by</span> <a href="https://h3rald.com/hastyscribe"><span class="hastyscribe"></span></a></p> </div> </body>