Skip to content

rmarkdown to html: tables do not render if + or - present in header row #2765

Closed
oliverdrechsel opened this Issue · 6 comments

2 participants

@oliverdrechsel

As soon as one puts strings ending with '+' or '-' in the header of tables, they will not render as table, but as normal text, in html.

The issue was described with example data here:
http://stackoverflow.com/questions/35798605/how-to-markdown-html-tables-containing-plus-minus

@jgm
Owner
jgm commented

Example from linked post:

|               | IP_gene8-_1st| IP_gene8+_1st| 
|:--------------|-------------:|-------------:|
|IP_gene8-_1st  |     1.0000000|     0.4357325|
|IP_gene8+_1st  |     0.4357325|     1.0000000|
@jgm
Owner
jgm commented

Minimal cases:

| a-_b |
|------|
| 1    |
| a+_b |
|----|
|  1|
@jgm
Owner
jgm commented

Interestingly revealing case:

pandoc -t native
| a |
|----| 
| a+_b |
| 1 |
^D
[Table [] [AlignDefault] [0.0]
 [[Plain [Str "a"]]]
 [[[Plain [Str "a+_b",Space,Str "|",SoftBreak,Str "|",Space,Str "1",Space,Str "|"]]]]]
@jgm
Owner
jgm commented

Workaround until the bug is fixed: escape the _ characters as \_.

@jgm
Owner
jgm commented

Note also that pandoc allows + as well as | as a pipe separator. (This is to achieve compatibility with org-mode tables, which are easy to create in Emacs.)

So literal + characters should be backslash-escaped.

@oliverdrechsel

I tried a bit more and it seems the \_ is necessary to get a valid html table.

a+_b doesn't work
a\+_b doesn't work
a+\_b works
a+b works

@jgm jgm added a commit that referenced this issue
@jgm Markdown reader: don't cross line boundary parsing pipe table row.
Previously an emph element could be parsed across the newline
at the end of the pipe table row.

I thought this would help with #2765, but it doesn't.
4ed6483
@jgm jgm added a commit that closed this issue
@jgm Markdown reader: Improved pipe table parsing.
Fixes #2765.
Added test case.
2b55b76
@jgm jgm closed this in 2b55b76
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.