alan-if / alan-docs

Alan IF Documentation Project
https://git.io/alan-docs
Other
3 stars 0 forks source link

Fix 1st Line Indentation in Code Blocks #70

Closed tajmone closed 3 years ago

tajmone commented 4 years ago

Problem

In documents that use Highlight, after an Alan code block starting with an indentation is processed by Highlight, the indentation on the first line is lost.

EDIT — The problem was fixed at it's root by editing the Haml template and using the :preserve filter to ensure that indentation of 1st line is always preserved correctly:

      %pre{:class=>pre_class, :lang=>pre_lang}
        %code{:class=>code_class, 'data-lang'=>code_lang}
          :preserve
            #{content}

For more info on this problem, see: tajmone/hugo-book#15

For an example, see:

The {wj} Workaround

EDIT: No longer required, problem fixed!

Right now, the only workaround solution is to add a word joiner character (⁠) at the beginning of the first indented line using its predefined attribute for character replacement ({wj}):

[source,alan, subs="+attributes"]
---------------------------------
{wj}  Add To Every object

This works fine, although it's far from being an ideal solution (but, at least, it shouldn't create any problems for other Asciidoctor backends and output formats).

tajmone commented 3 years ago

This problem seems to affect only documents using Highlight, not those using Highlight.js.

Highlight.js Note

Currently the ALAN Manual still uses Highlight.js, due to the presence of some callouts (See #36, #50).

So this problem doesn't affect the ALAN Manual — I've checked every single code block in the book, and there's no trace of this indentation problem.

Highlight Note

This problem affects The Beginner's Guide, I just need to check if I've already applied the {wj} fix to all occurences of the problem.

Note, if/when we switch also the ALAN Manual to use Highlight (see #50) there might be a Lua filter to handle this problem, among those that ship with Highlight (if I remember correctly).