Change line numbering according to markdown specifications

Use case or problem

In “Editor/Display” I use the option “Show line numbers”. To ignore single line breaks in preview mode, I use the setting “Editor/Display/Strict Line Limit” according to the Markdown specifications.
With these settings it would make sense if after single line breaks no new line number is displayed but only after entering “Double Space+ Enter” or if a new paragraph is started.

Proposed solution

Create with above settings only a new line number after entering:

  • Space+Space+Enter or
  • Enter,Enter

Current workaround (optional)


They’re line numbers, not paragraph numbers.

(Paragraph numbers would be a useful feature, tho.)

1 Like

Yes, and a single „Return“ or „Enter“ creates no new line according to markdown standards. Therefore, in live preview a single „Return/Enter“ should not create a new line number.
In standard markdown a new line is created only by typing „Space+Space+Enter“.

I am not talking about paragraphs here.

According to the Commonmark standard used by Obsidian, “A line is a sequence of zero or more characters other than line feed (U+000A ) or carriage return (U+000D ), followed by a line ending or by the end of file.” — CommonMark Spec (“A line ending is a line feed (U+000A ), a carriage return (U+000D ) not followed by a line feed, or a carriage return and a following line feed.” — CommonMark Spec)

The original description of Markdown doesn’t define lines, but it clearly describes lines created by a single return:

A paragraph is simply one or more consecutive lines of text, separated by one or more blank lines. (A blank line is any line that looks like a blank line — a line containing nothing but spaces or tabs is considered blank.) Normal paragraphs should not be indented with spaces or tabs.

The implication of the “one or more consecutive lines of text” rule is that Markdown supports “hard-wrapped” text paragraphs. This differs significantly from most other text-to-HTML formatters (including Movable Type’s “Convert Line Breaks” option) which translate every line break character in a paragraph into a <br />tag.

Daring Fireball: Markdown Syntax Documentation

Thank you @CawlinTeffid very much for these explanations. I probably expressed my suggestion for improvement incorrectly due to my limited English.
I just suggest that a new line number is displayed only after a <br /> or <p /> tag.
If I understood correctly, with the above settings, you insert a <br /> tag and end a line only by writing two or more spaces and then type a return.

I hope that explains it better.

I understand what you are after here but Live Preview, while mimicking some aspects of the Reader experience it is still and will be an editor. Line numbers are for the editor not for the rendered markdown. Moved to plugin ideas.

1 Like

Thank you. While I hadn’t fully understood what you meant earlier, I got that you wanted something different from standard line numbering which would be its own possibly useful feature.

Your English is good. The only thing that showed it’s not your first language was your quotation marks (and the intent of those is still clear).

OK, thanks everybody.