davidfarmer / LaTeXtoLaTeX

Utilities for converting LaTeX markup to a standard form
1 stars 8 forks source link

Respect indentation for multi-line verbatim text #28

Open rbeezer opened 4 years ago

rbeezer commented 4 years ago

PreTeXt supports multi-line "verbatim" input, with the intent to respect indentation. For code that needs to actually needs to run (e.g. Python in a program for Runestaone use, Sage in a sage for the Sage cell). But also for purely visual uses, like a pre.

Pretty-printing seems to be removing this. Reviewing sample article output from

ltol.py xml_pp mathbook/examples/sample-article/ .

PreTeXt has a template to strip "common" leading whitespace from multi-line bare text. For pretty-printing purposes, I'd think you want to mimic most/all of this, and then add in the current indentation as whitespace? At least see documentation of effect:

https://github.com/rbeezer/mathbook/blob/512bf5d956f01262bf245f8cf45d8607e0f3a54e/xsl/pretext-common.xsl#L2660

Or maybe you know what current indentation is and believe source is respecting that for multi-line text and you can just work off the delta between author's indentation and destination/pretty-printed output.

I think AATA Sage code is still a bit of a mess from this. But mostly the code is one-liners so not too much had to be re-indented to run. But for an author with lots of Python/Sage, this would be a problem.

And I forgot about asymptote, sageplot, latex-image which could be entirely similar. Some of that, and some of this is on #23.

rbeezer commented 4 years ago

Long story, bad cut/paste job. Just edited-in a new first paragraph.

davidfarmer commented 4 years ago

The script claims that "pre" is in the list of varbatim tags, which is supposed to mean that whitespace is not stripped.

I will investigate.

On Sat, 21 Nov 2020, Rob Beezer wrote:

Pretty-printing seems to be removing this. Reviewing sample article output from

ltol.py xml_pp mathbook/examples/sample-article/ .

  • c leads to some long lines, but they are partly testing artifacts, all OK
  • cd, w/ and w/out cline structure, look great. Indented consistent with surroundings.
  • pre and pre/cline entirely flush left, both elements and multi-line bare text
  • program/input entirely flush left (both elements, and code), indentation clobbered
  • sage/input entirely flush left (both elements, and code), indentation clobbered

PreTeXt has a template to strip "common" leading whitespace from multi-line bare text. For pretty-printing purposes, I'd think you want to mimic most/all of this, and then add in the current indentation as whitespace? At least see documentation of effect:

https://github.com/rbeezer/mathbook/blob/512bf5d956f01262bf245f8cf45d8607e0f3a54e/xsl/pretext -common.xsl#L2660

Or maybe you know what current indentation is and believe source is respecting that for multi-line text and you can just work off the delta between author's indentation and destination/pretty-printed output.

I think AATA Sage code is still a bit of a mess from this. But mostly the code is one-liners so not too much had to be re-indented to run. But for an author with lots of Python/Sage, this would be a problem.

And I forgot about asymptote, sageplot, latex-image which could be entirely similar. Some of that, and some of this is on #23.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, orunsubscribe.[AABTULDLCL5UNORT3HOCKBLSRAS4NA5CNFSM4T6AOIWKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33N NVSW45C7NFSM4LEXEFKA.gif]