comprehensive-rust
comprehensive-rust copied to clipboard
Lines not wrapping in PDF tables
The Android Build Rules chapter has a table with text which should wrap. The PDFs currently don't wrap the lines:
I like the LaTeX environment used for the table a lot, we just need to extend it a bit to support wrapped text.
Cc @max-heller.
This is a known issue. LaTeX will wrap the contents of cells if given relative widths to constrain each column. Pandoc sets these widths if its standard markdown parser is used but not if its Commonmark parser is used (see https://github.com/jgm/commonmark-hs/issues/128).
As a workaround, it should work to write a Pandoc filter that sets the width for each column to 1/n (n being the number of columns), though this will force tables that could be represented more compactly to take up the full width of the page
Ah, thanks, I hadn't looked there!
LaTeX will wrap the contents of cells if given relative widths to constrain each column.
Yes, I remember being able to control the column widths back in the day when writing LaTeX directly. It's been several years, but I still have the good old LaTex Companion somewhere :smile:
As a workaround, it should work to write a Pandoc filter that sets the width for each column to 1/n (n being the number of columns), though this will force tables that could be represented more compactly to take up the full width of the page
Nice idea! Would it also be possible to embed a small "language" for this in a HTML comment in the Markdown? If a Pandoc filter has access to this, then that could be a nice way to do it:
<!-- Pandoc columns: default 0.8 -->
| Module Type | Description |
|----------------|-------------------------------------------------------------------------|
| `rust_binary` | Produces a Rust binary. |
| `rust_library` | Produces a Rust library, and provides both `rlib` and `dylib` variants. |
could perhaps be parsed and used to attach a ColWidthDefault and ColWidth 0.8 value to each column?
Nice idea! Would it also be possible to embed a small "language" for this in a HTML comment in the Markdown? If a Pandoc filter has access to this, then that could be a nice way to do it:
<!-- Pandoc columns: default 0.8 --> | Module Type | Description | |----------------|-------------------------------------------------------------------------| | `rust_binary` | Produces a Rust binary. | | `rust_library` | Produces a Rust library, and provides both `rlib` and `dylib` variants. |could perhaps be parsed and used to attach a
ColWidthDefaultandColWidth 0.8value to each column?
That sounds like it'd work, the HTML comment should be included in the Pandoc AST as a RawBlock
Okay, cool! I don't know if there is precedent for "smuggling" information through like that in Pandoc?
We've done something very similar for the text extraction in mdbook-xgettext: there you can add <!-- mdbook-xgettext:skip --> to skip the next block.
I don't know if there is precedent for "smuggling" information through like that in Pandoc?
There are a lot of examples out there, I'm sure someone's implemented something similar
Nice!
I won't be putting a lot of work into this myself, so the issue is here in case someone else finds the time to work on this. I can ask internally if someone wants to contribute their 20% time to it.