niklasfasching / go-org

Org mode parser with html & pretty printed org rendering. also shitty static site generator.
https://niklasfasching.github.io/go-org/
MIT License
355 stars 49 forks source link

Newline within paragraph support #90

Closed braoult closed 2 years ago

braoult commented 2 years ago

Org documentation states : "If you need to enforce a line break within a paragraph, use ‘\\’ at the end of a line.".

For example :

- =line1=\\
  =line2=

Should be rendered as something like (as rendered on github) :

<li>
<code>line1</code>
<br>
<code>line2</code>
</li>

However, something breaks (see below without the \\) and we get :

<li>
<code>
line1=\\=line2
</code>
</li>

The \\ not only does not insert a newline, but seems to break the parsing. The same example without them :

- =line1=
  =line2=

Correctly parses two distinct code blocks (which will be rendered on same line) :

<li>
<code>line1</code>
<code>line2</code>
</li>

EDIT: Adding a space before the \\ solves the issue (a newline is inserted, and there is no parsing issue). I am unclear about what org-mode says here. I can live with that and add spaces; but, to be sure, I could ask an org-mode maintainer if =foo=\\ is the same as =foo= \\ if you want.

niklasfasching commented 2 years ago

Awesome report, thx!

Fixed in https://github.com/niklasfasching/go-org/commit/f27340ed5e7f5cd10cb996eea9135246a5b689f7 (TLDR: copied the org regex for post emphasis chars wrongly, \ now added)