asciidoctor / asciidoctor-mathematical

An extension for Asciidoctor that converts the content of STEM blocks and inline macros using Mathematical.
MIT License
50 stars 46 forks source link

Hard line breaks in block AsciiMath are not preserved #91

Open mojavelinux opened 3 years ago

mojavelinux commented 3 years ago

AsciiMath blocks require special line handling. You can find the logic here: https://github.com/asciidoctor/asciidoctor/blob/dd843d59b1e49f29d68386bfdf0438ce11b42577/lib/asciidoctor/converter/html5.rb#L697

The rules are as follows:

  1. Two lines separated by only a newline character become a single line (the current behavior)
  2. A line that ends with \ should become a hard line break
  3. A double line break (and any additional line breaks) should be preserved (effectively separating the equations).

2 & 3 are not honored.

See https://github.com/asciidoctor/asciidoctor/issues/2497#issuecomment-369865944 for the specification and examples.

SpyrosRoum commented 3 years ago

Hey do you think this might be something easy for someone who doesn't know ruby to implement? I really like asciidoctor so far and you have already helped me so I'd like to give back! Learning Ruby is not in my todo list but I already know python and Rust so maybe I can hack something together based on the logic you linked

christopherball commented 3 years ago

+1 for supporting hard line breaks in native AsciiMath syntax. This is a major pain for my tooling right now, as I ended up going with the approach of translating /r's into separate `` chunks, which means I can't save off a single SVG since they're considered separate blocks. Any ETA on getting a fully supported line break in place?

mojavelinux commented 3 years ago

@SpyrosRoum This seems relatively straightforward to implement. I'd be happy to mentor you if you need assistance.

mcp292 commented 1 year ago

@SpyrosRoum @mojavelinux Thank you both for dedicating your time to this. @mojavelinux Thank you for being so welcoming and helpful.

Has any progress been made on this front? I ran into this on:

$ asciidoctor-pdf -v
----
Asciidoctor PDF 2.3.4 using Asciidoctor 2.0.18 [https://asciidoctor.org]
Runtime Environment (ruby 3.0.4p208 (2022-04-12 revision 3fa771dded) [x86_64-linux]) (lc:UTF-8 fs:UTF-8 in:UTF-8 ex:UTF-8)

Edit:
I'm also having this problem when using :stem: latexmath.

mojavelinux commented 1 year ago

I'm also having this problem when using :stem: latexmath.

It seems this problem is not limited to AsciiMath.