alan-if / alan-docs

Alan IF Documentation Project

Home Page:https://git.io/alan-docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fix 1st Line Indentation in Code Blocks

tajmone opened this issue · comments

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.

  • ALAN Beginner's Guide:
    • Fix all occurrences in current sources using the {wj} workaround.
    • Before committing, check that it doesn't interfere with:
      • PDF builds (via Asciidoc-fopub).
    • Found a real fix to the problem by editing the Haml template.

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).

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).