jgm / pandoc

Universal markup converter
https://pandoc.org
Other
34.39k stars 3.37k forks source link

man format produce mangled table #7066

Closed dotnetCarpenter closed 3 years ago

dotnetCarpenter commented 3 years ago

Disclaimer: I'm not 100% sure if this is a bug in pandoc or groff, since I can not read man format.

Takes the following pipe table example:

| Right | Left | Default | Center |
|------:|:-----|---------|:------:|
|   12  |  12  |    12   |    12  |
|  123  |  123 |   123   |   123  |
|    1  |    1 |     1   |     1  |

  : Demonstration of pipe table syntax.

Converting that to man seems to produce mangled output. Outputting HTML however seems fine.

pandoc -f gfm+pipe_tables -t man Command: ``` pandoc -s -f gfm+pipe_tables -t man "$1" | groff -T utf8 -man > less.$$ less less.$$ rm less.$$ ``` Output: ``` () () tab(@); r l l c. T{ Right T}@T{ Left T}@T{ Default T}@T{ Center T} _ T{ 12 T}@T{ 12 T}@T{ 12 T}@T{ 12 T} T{ 123 T}@T{ 123 T}@T{ 123 T}@T{ 123 T} T{ 1 T}@T{ 1 T}@T{ 1 T}@T{ 1 T} : Demonstration of pipe table syntax. () less.20150 (END) ```
pandoc -f gfm -t man Command: ``` pandoc -s -f gfm -t man "$1" | groff -T utf8 -man > less.$$ less less.$$ rm less.$$ ``` Output: ``` () () tab(@); r l l c. T{ Right T}@T{ Left T}@T{ Default T}@T{ Center T} _ T{ 12 T}@T{ 12 T}@T{ 12 T}@T{ 12 T} T{ 123 T}@T{ 123 T}@T{ 123 T}@T{ 123 T} T{ 1 T}@T{ 1 T}@T{ 1 T}@T{ 1 T} : Demonstration of pipe table syntax. () less.23002 (END) ```
pandoc -s -f gfm (HTML) Command: `pandoc -s -f gfm --metadata pagetitle="$1" "$1" | elinks -dump` Output: ``` Right Left Default Center 12 12 12 12 123 123 123 123 1 1 1 1 : Demonstration of pipe table syntax. ``` The third example looks fine. Even without the `+pipe_tables` extension. I guess the extension is included in `gfm`.
jgm commented 3 years ago

Add -t to your groff invocation to run the tbl preprocessor and it will be fine.

(The man command will do this automatically by the way because of the comment

'\" t

on teh first line.)

dotnetCarpenter commented 3 years ago

Thanks @jgm!

Sorry for posting a non-bug here.

For everyone else who reads this, note that it works as advertised but I get:

troff: <standard input>:72: warning [p 1, 0.8i, div '3tbd6,2', 0.8i]: cannot adjust line
troff: <standard input>:110: warning [p 1, 0.8i, div '3tbd10,2', 0.2i]: can't break line

pandoc 2.5 Compiled with pandoc-types 1.17.5.4, texmath 0.11.2.2, skylighting 0.7.7 GNU groff version 1.22.4 GNU troff (groff) version 1.22.4

It's a minor cosmetic issue. Probably with groff