Skip to content

Missing <p> when converting from OrgMode #2464

Closed
rgaiacs opened this Issue · 3 comments

3 participants

@rgaiacs

Minimal working Example

$ cat sample.org
* DONE Title
  CLOSED: [2015-10-19 Mon 15:03]
  - Note taken on [2015-10-19 Mon 13:24] \\
    Some note.

Currently Output

$ pandoc -f org -t html sample.org
<h1>DONE Title</h1>
CLOSED: [2015-10-19 Mon 15:03]
<ul>
<li>Note taken on [2015-10-19 Mon 13:24]<br />
 Some note.</li>
</ul>

Expected Output

$ pandoc -f org -t html sample.org
<h1>DONE Title</h1>
<p>CLOSED: [2015-10-19 Mon 15:03]</p>
<ul>
<li>Note taken on [2015-10-19 Mon 13:24]<br />
 Some note.</li>
</ul>

Extra Information

If there is no list after the time stamp the output is OK.

$ cat sample.org 
* DONE Title
  CLOSED: [2015-10-19 Mon 15:03]
$ pandoc -f org -t html sample.org
<h1>DONE Title</h1>
<p>CLOSED: [2015-10-19 Mon 15:03]</p>

Environment

$ uname -a
Linux pupunha 4.1.0-1-amd64 #1 SMP Debian 4.1.3-1 (2015-08-03) x86_64 GNU/Linux
$ pandoc --version
pandoc 1.15.0.3
@jgm
Owner
@jgm
Owner

I can see why this is happening:

-- Paragraphs or Plain text                                                     
paraOrPlain :: OrgParser (F Blocks)
paraOrPlain = try $ do
  ils <- parseInlines
  nl <- option False (newline >> return True)
  try (guard nl >> notFollowedBy (orderedListStart <|> bulletListStart) >>
           return (B.para <$> ils))
    <|>  (return (B.plain <$> ils))

In this case the "CLOSED:" text is followed directly by a bullet list item, so we get a Plain rather than a Para.

This is in fact just what you want in nested list contexts like:

* a
  * b
    * c

Here b is a Plain because it's followed directly by an ordered list, with no blank space. This gives you a "tight" list.

Perhaps, though, we could make an exception when we're not in a list context at all, as in the original example.

@tarleb

Making an exception here seems reasonable. Thanks for the report @rgaiacs, I'll try to fix this soonish.

@tarleb tarleb added a commit to tarleb/pandoc that referenced this issue
@tarleb tarleb Org reader: fix paragraph/list interaction
Paragraphs can be followed by lists, even if there is no blank line
between the two blocks.  However, this should only be true if the
paragraph is not within a list, were the preceding block should be
parsed as a plain instead of paragraph (to allow for compact lists).

Thanks to @rgaiacs for bringing this up.

This fixes #2464.
b273667
@jgm jgm closed this in #2475
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.