norg-specs icon indicating copy to clipboard operation
norg-specs copied to clipboard

[Discussion]: Preceding whitespace rule for verbatim ranged tags

Open boltlessengineer opened this issue 10 months ago • 1 comments

Related: https://github.com/nvim-neorg/neorg/issues/946

We should have strict rule for ignoring preceding whitespaces in verbatim ranged tag content.

Example:

  @code
  text
    text
  @end

The expected verbatim ranged tag content should not include 2 spaces in each lines. This is crucial to embed indent-dependent languages like Python.

Idea

Follow the starting column of opening modifier (in this case, @code.) Ignore same amount of whitespaces on content lines if there are any.

I'm not sure how we should handle tabs or zero/full-width spaces though.

boltlessengineer avatar Mar 15 '25 15:03 boltlessengineer

Or we can just live without any special rules:

   @code
text
  text
@end

In this case, Neorg-like applications should implement some anticonceal characters to align the verbatim ranged tag content with its starting token (@code)

boltlessengineer avatar Mar 19 '25 17:03 boltlessengineer

In what case would there be an indent before a verbatim ranged tag? If it's in a list, eg.

- @code
  foo(bar)
  @end 

Isn't this already handled by list parsing logic?

flexagoon avatar May 01 '25 03:05 flexagoon

@flexagoon v1 spec and parser didn't have same issue because verbatim ranged tag cannot be indented by its own:

- |
  @code
  foo(bar)
  @end

slides/indent segments forced @code to come at the beginning of the line, without any prefix characters like - or >.

But in v2 spec, this is possible:

- @code
  foo(bar)
  @end

Which means now we have to set rule that can work for both - and .

Yeah v1 parser and neorg itself worked in similar way^1, but I couldn't found anything mentioned on specification. (v1 parser actually ignored the preceding whitespaces inside verbatim ranged tag. neorg did all heavy lift) This is quite important because using column means we have specific width defined for \t character. That's why I'm opening this issue to set standard in v2 spec. There are also full-width space and zero-width space.

boltlessengineer avatar May 01 '25 03:05 boltlessengineer