Skip to content

Fix hanging indents for admonition (eg NOTE) blocks#41

Draft
hjwp wants to merge 1 commit intocathaysia:masterfrom
hjwp:some-bugs
Draft

Fix hanging indents for admonition (eg NOTE) blocks#41
hjwp wants to merge 1 commit intocathaysia:masterfrom
hjwp:some-bugs

Conversation

@hjwp
Copy link
Copy Markdown

@hjwp hjwp commented Feb 19, 2025

Hi there, not sure if bug reports / suggestions are welcome, but I noticed some strange highlighting for "hanging indented" blocks. I noticed it with NOTE: admonitions, but it also happens for <1> callouts. example:

NOTE: Line 1
  Line 2

highlights as:

image

looking at InspectTree, i think it's recognising the second line as being a separate block?

  (block_element ; [1, 0] - [2, 0]
    (section_block ; [1, 0] - [2, 0]
      (admonition ; [1, 0] - [2, 0]
        (admonition_note) ; [1, 0] - [1, 4]
        (line)))) ; [1, 6] - [2, 0]
  (block_element ; [2, 0] - [3, 0]
    (section_block ; [2, 0] - [3, 0]
      (ident_block ; [2, 0] - [3, 0]
        (ident_block_line ; [2, 0] - [3, 0]
          (ident_marker)))))) ; [2, 0] - [2, 2]

In an attempt to be hepful, I've tried to add an example in the tests corpus, with my non-expert best guess as to what the tree should be?

@hjwp hjwp changed the title Fix hangin indents for admonition (eg NOTE) blocks Fix hanging indents for admonition (eg NOTE) blocks Feb 19, 2025
@hjwp
Copy link
Copy Markdown
Author

hjwp commented Feb 19, 2025

PS - looking at the asciidoc documentation, maybe hanging indents like this aren't explicitly part of the spec?

https://docs.asciidoctor.org/asciidoc/latest/blocks/admonitions/

it's certainly how i've always written them, i find it easier to visually see my NOTE blocks stand out. but i'll understand if you want to say the spec is unclear on this, and you want to put it out of scope.

@hjwp
Copy link
Copy Markdown
Author

hjwp commented Feb 19, 2025

otoh both legacy asciidoc and asciidoctor have always parsed my indented note blocks correctly!

@bonusnunc
Copy link
Copy Markdown
Contributor

Maybe a related issue: When a list item spans multiple lines, the lines after the first one are also highlighted:
Captura desde 2025-02-19 07-30-56
The red color in my theme applies to the note sample given by @hjwp

@cathaysia
Copy link
Copy Markdown
Owner

cathaysia commented Feb 20, 2025

The problem with this bug is that the parser only considers admonition as one line. But asciidoctor requires two consecutive NEW_LINE or EOF.
This is indeed a bug

@bonusnunc list item also has the similar problem.

@cathaysia
Copy link
Copy Markdown
Owner

not sure if bug reports / suggestions are welcome

There are always welcome.

But please follow this specification for git commit message:

https://www.conventionalcommits.org/en/v1.0.0/

@hjwp
Copy link
Copy Markdown
Author

hjwp commented Apr 15, 2025

Hi, I changed the commit message, lmk if that now follows the conventions you prefer?

it's only the test so far I'm afraid! I don't feel qualified to attempt the actual fix 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants