<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Ssg on Bastien Traverse</title>
    <link>https://bastientraverse.com/en/tags/ssg/</link>
    <description>Recent content in Ssg on Bastien Traverse</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Sun, 02 May 2021 00:00:00 +0200</lastBuildDate><atom:link href="https://bastientraverse.com/en/tags/ssg/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Editor-induced bugs</title>
      <link>https://bastientraverse.com/en/editor-induced-bugs/</link>
      <pubDate>Sun, 02 May 2021 00:00:00 +0200</pubDate>
      
      <guid>https://bastientraverse.com/en/editor-induced-bugs/</guid>
      <description>&lt;p&gt;While working on this site, I suddenly noticed that an extra space was added after any link, but it was only visible when that link was followed by another character like a parenthesis.&lt;/p&gt;
&lt;p&gt;I dug hard and on a hunch, found that it was caused by my &lt;a href=&#34;https://gitlab.com/neitsab/bastientraverse.com/-/commit/387534693548bdf0e61d62df12f723ac98167f8c&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;recent addition of a render hook for links&lt;/a&gt;. I had simply &lt;a href=&#34;https://gohugo.io/templates/render-hooks/#link-with-title-markdown-example&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;followed the instructions&lt;/a&gt; and added the following snippet in &lt;code&gt;layouts/_default/_markup/render-link.html&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-go&#34; data-lang=&#34;go&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;a&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;href&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;{{ .Destination | safeURL }}&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{{&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;with&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;Title&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}}&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;title&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;{{ . }}&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{{&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;end&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;}}{{&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;strings&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;HasPrefix&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;Destination&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;&amp;#34;http&amp;#34;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;}}&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;target&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;_blank&amp;#34;&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;rel&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;noopener&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{{&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;end&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;}}&amp;gt;{{&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;Text&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;safeHTML&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;}}&amp;lt;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;a&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Eventually, I found this &lt;a href=&#34;https://github.com/gohugoio/hugo/issues/6949&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Hugo bug&lt;/a&gt; that enlightened me: turns out some text editors automatically add a newline at the end of the file on save to comply with the &lt;a href=&#34;https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;POSIX standard definition of a line &lt;/a&gt;(&lt;a href=&#34;https://stackoverflow.com/questions/729692/why-should-text-files-end-with-a-newline&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;source&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;This other &lt;a href=&#34;https://stackoverflow.com/questions/3056740/gedit-adds-line-at-end-of-file&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;StackOverflow thread&lt;/a&gt; lists &lt;a href=&#34;https://web.archive.org/web/20230530154654/https://bugzilla.gnome.org/show_bug.cgi?id=625955&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;some&lt;/a&gt; Gedit &lt;a href=&#34;https://bugzilla.gnome.org/show_bug.cgi?id=526612&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;bugs&lt;/a&gt; where devs don&amp;rsquo;t want to add at least a GUI option to enable/disable the automatic addition of newline (the option now exists in gsettings), nor to simply display it&amp;hellip; Some more discussion of this issue on &lt;a href=&#34;https://discourse.gohugo.io/t/markdown-render-hooks-extra-space/27446&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Hugo Forums&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The Hugo-specific solution was to add a Go template snippet at the end of the render hooks which removes trailing newlines (&lt;a href=&#34;https://discourse.gohugo.io/t/markdown-render-hooks-extra-space/27446/5&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;credit&lt;/a&gt;):&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-diff&#34; data-lang=&#34;diff&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;gh&#34;&gt;diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;gh&#34;&gt;index f04b2e3bda072e15cf8ac7787e37e68744a76048..06727fbe334a084ad29a29a85caf8f3a4fd55bda 100644
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;gh&#34;&gt;&lt;/span&gt;&lt;span class=&#34;gd&#34;&gt;--- a/layouts/_default/_markup/render-link.html
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;gd&#34;&gt;&lt;/span&gt;&lt;span class=&#34;gi&#34;&gt;+++ b/layouts/_default/_markup/render-link.html
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;gi&#34;&gt;&lt;/span&gt;&lt;span class=&#34;gu&#34;&gt;@@ -1 +1,2 @@
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;gu&#34;&gt;&lt;/span&gt; &amp;lt;a href=&amp;#34;{{ .Destination | safeURL }}&amp;#34;{{ with .Title}} title=&amp;#34;{{ . }}&amp;#34;{{ end }}{{ if strings.HasPrefix .Destination &amp;#34;http&amp;#34; }} target=&amp;#34;_blank&amp;#34; rel=&amp;#34;noopener&amp;#34;{{ end }}&amp;gt;{{ .Text | safeHTML }}&amp;lt;/a&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;gi&#34;&gt;+{{- /* This comment removes trailing newlines. */ -}}
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Information technology is such a complex interaction of countless moving parts, that I often wonder how it can work and produce any results at all!&lt;/p&gt;
</description>
    </item>
    
  </channel>
</rss>
