summaryrefslogtreecommitdiff
path: root/gemfeed/2021-06-05-gemtexter-one-bash-script-to-rule-it-all.html
diff options
context:
space:
mode:
Diffstat (limited to 'gemfeed/2021-06-05-gemtexter-one-bash-script-to-rule-it-all.html')
-rw-r--r--gemfeed/2021-06-05-gemtexter-one-bash-script-to-rule-it-all.html26
1 files changed, 13 insertions, 13 deletions
diff --git a/gemfeed/2021-06-05-gemtexter-one-bash-script-to-rule-it-all.html b/gemfeed/2021-06-05-gemtexter-one-bash-script-to-rule-it-all.html
index 93ac8aea..edbdab2b 100644
--- a/gemfeed/2021-06-05-gemtexter-one-bash-script-to-rule-it-all.html
+++ b/gemfeed/2021-06-05-gemtexter-one-bash-script-to-rule-it-all.html
@@ -8,7 +8,7 @@
<link rel="stylesheet" href="style-override.css" />
</head>
<body>
-<h1 style='display: inline'>Gemtexter - One Bash script to rule it all</h1><br />
+<h1 style='display: inline' id='GemtexterOneBashscripttoruleitall'>Gemtexter - One Bash script to rule it all</h1><br />
<br />
<span class='quote'>Published at 2021-06-05T19:03:32+01:00</span><br />
<br />
@@ -57,7 +57,7 @@
<br />
<span>This comes with the benefit that I can write content in my favourite text editor (Vim). </span><br />
<br />
-<h2 style='display: inline'>Motivation</h2><br />
+<h2 style='display: inline' id='Motivation'>Motivation</h2><br />
<br />
<span>Another benefit of using Gemini is that the Gemtext markup language is easy to parse. As my site is dual-hosted (Gemini+HTTP), I could, in theory, just write a shell script to deal with the conversion from Gemtext to HTML; there is no need for a full-featured programming language here. I have done a lot of Bash in the past, but I am also often revisiting old tools and techniques for refreshing and keeping the knowledge up to date here.</span><br />
<br />
@@ -69,7 +69,7 @@
<br />
<span>In short, Gemtexter is a static site generator and blogging engine that uses Gemtext as its input format.</span><br />
<br />
-<h2 style='display: inline'>Output formats</h2><br />
+<h2 style='display: inline' id='Outputformats'>Output formats</h2><br />
<br />
<span>Gemtexter takes the Gemtext Markup files as the input and generates the following outputs from it (you find examples for each of these output formats on the Gemtexter GitHub page):</span><br />
<br />
@@ -82,11 +82,11 @@
</ul><br />
<span>I could have done all of that with a more robust language than Bash (such as Perl, Ruby, Go...), but I didn&#39;t. The purpose of this exercise was to challenge what I can do with a "simple" Bash script and learn new things.</span><br />
<br />
-<h2 style='display: inline'>Taking it as far as I should, but no farther</h2><br />
+<h2 style='display: inline' id='TakingitasfarasIshouldbutnofarther'>Taking it as far as I should, but no farther</h2><br />
<br />
<span>The Bash is suitable very well for small scripts and ad-hoc automation on the command line. But it is for sure not a robust programming language. Writing this blog post, Gemtexter is nearing 1000 lines of code, which is actually a pretty large Bash script.</span><br />
<br />
-<h3 style='display: inline'>Modularization </h3><br />
+<h3 style='display: inline' id='Modularization'>Modularization </h3><br />
<br />
<span>I modularized the code so that each core functionality has its own file in ./lib. All the modules are included from the main Gemtexter script. For example, there is one module for HTML generation, one for Markdown generation, and so on. </span><br />
<br />
@@ -110,7 +110,7 @@ http://www.gnu.org/software/src-highlite -->
<br />
<span>This way, the script could grow far beyond 1000 lines of code and still be maintainable. With more features, execution speed may slowly become a problem, though. I already notice that Gemtexter doesn&#39;t produce results instantly but requires few seconds of runtime already. That&#39;s not a problem yet, though. </span><br />
<br />
-<h3 style='display: inline'>Bash best practises and ShellCheck</h3><br />
+<h3 style='display: inline' id='BashbestpractisesandShellCheck'>Bash best practises and ShellCheck</h3><br />
<br />
<span>While working on Gemtexter, I also had a look at the Google Shell Style Guide and wrote a blog post on that:</span><br />
<br />
@@ -126,7 +126,7 @@ http://www.gnu.org/software/src-highlite -->
<br />
<a class='textlink' href='https://shellcheck.net'>https://shellcheck.net</a><br />
<br />
-<h3 style='display: inline'>Unit testing</h3><br />
+<h3 style='display: inline' id='Unittesting'>Unit testing</h3><br />
<br />
<span>There is a basic unit test module in ./lib/assert.source.sh, which is used for unit testing. I found this to be very beneficial for cross-platform development. For example, I noticed that some unit tests failed on macOS while everything still worked fine on my Fedora Linux laptop. </span><br />
<br />
@@ -134,7 +134,7 @@ http://www.gnu.org/software/src-highlite -->
<br />
<span>It has been proven quite helpful to have unit tests in place for the HTML part already when working on the Markdown generator part. To test the Markdown part, I copied the HTML unit tests and changed the expected outcome in the assertions. This way, I could implement the Markdown generator in a test-driven way (writing the test first and afterwards the implementation).</span><br />
<br />
-<h3 style='display: inline'>HTML unit test example</h3><br />
+<h3 style='display: inline' id='HTMLunittestexample'>HTML unit test example</h3><br />
<br />
<!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
@@ -145,7 +145,7 @@ assert<font color="#990000">::</font>equals <font color="#FF0000">"$(generate::m
<font color="#FF0000">'&lt;a class="textlink" href="http://example.org"&gt;Description of the link&lt;/a&gt;&lt;br /&gt;'</font>
</pre>
<br />
-<h3 style='display: inline'>Markdown unit test example</h3><br />
+<h3 style='display: inline' id='Markdownunittestexample'>Markdown unit test example</h3><br />
<br />
<!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
@@ -156,7 +156,7 @@ assert<font color="#990000">::</font>equals <font color="#FF0000">"$(generate::m
<font color="#FF0000">'[Description of the link](http://example.org) '</font>
</pre>
<br />
-<h2 style='display: inline'>Handcrafted HTML styles</h2><br />
+<h2 style='display: inline' id='HandcraftedHTMLstyles'>Handcrafted HTML styles</h2><br />
<br />
<span>I had a look at some ready off the shelf CSS styles, but they all seemed too bloated. There is a whole industry selling CSS styles on the interweb. I preferred an effortless and minimalist style for the HTML site. So I handcrafted the Cascading Style Sheets manually with love and included them in the HTML header template. </span><br />
<br />
@@ -164,11 +164,11 @@ assert<font color="#990000">::</font>equals <font color="#FF0000">"$(generate::m
<br />
<span>It&#39;s worth mentioning that all generated HTML files and Atom feeds pass the W3C validation tests.</span><br />
<span> </span><br />
-<h2 style='display: inline'>Configurability</h2><br />
+<h2 style='display: inline' id='Configurability'>Configurability</h2><br />
<br />
<span>In case someone else than me wants to use Gemtexter for his own site, it is pretty much configurable. It is possible to specify your own configuration file and your own HTML templates. Have a look at the GitHub page for examples.</span><br />
<br />
-<h2 style='display: inline'>Future features</h2><br />
+<h2 style='display: inline' id='Futurefeatures'>Future features</h2><br />
<br />
<span>I could think of the following features added to a future version of Gemtexter:</span><br />
<br />
@@ -178,7 +178,7 @@ assert<font color="#990000">::</font>equals <font color="#FF0000">"$(generate::m
<li>External CSS file for HTML.</li>
<li>Improve speed by introducing parallelism and/or concurrency and/or better caching.</li>
</ul><br />
-<h2 style='display: inline'>Conclusion</h2><br />
+<h2 style='display: inline' id='Conclusion'>Conclusion</h2><br />
<br />
<span>It was quite a lot of fun writing Gemtexter. It&#39;s a relatively small project, but given that I worked on that in my spare time once in a while, it kept me busy for several weeks. </span><br />
<br />