Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

text-to-kramdown-to-HTML discrepancy for dd,li with initial blank line #486

Open
ccorn opened this issue Jan 8, 2018 · 4 comments
Open
Assignees
Labels

Comments

@ccorn
Copy link
Contributor

ccorn commented Jan 8, 2018

Consider a file test.md with the following contents:

item
: 

    para

Caution: This has (and requires) a (horizontal) blank after the colon.
Let's try kramdown on it:

$ kramdown test.md
<dl>
  <dt>item</dt>
  <dd>

    <p>para</p>
  </dd>
</dl>

As expected (by me, at least). But the kramdown converter output is:

$ kramdown -o kramdown test.md
item
: para

which does not mark para as (explicit) paragraph.
Therefore, the corresponding HTML output now misses <p> tags:

$ kramdown -o kramdown test.md | kramdown
<dl>
  <dt>item</dt>
  <dd>para</dd>
</dl>

As a consequence, test cases like test.md trigger text-to-kramdown-to-html failures.
Update: Also occurs with other list types, see below.

@ccorn
Copy link
Contributor Author

ccorn commented Jan 8, 2018

The roughly equivalent input

item
: ^
  para

does not have that problem.

@ccorn ccorn changed the title text-to-kramdown-to-HTML discrepancy for dd with initial parsep text-to-kramdown-to-HTML discrepancy for dd with initial blank line Jan 8, 2018
@ccorn
Copy link
Contributor Author

ccorn commented Jan 8, 2018

Using irb, I find that test.md gets parsed to

=> <kd:root nil {:encoding=>#<Encoding:UTF-8>, :location=>1, :options=>{}, :abbrev_defs=>{}, :abbrev_attr=>{}} [<kd:dl nil {:location=>1, :ial=>nil} [<kd:dt nil {:location=>2, :raw_text=>"item"} [<kd:text "item" nil {:location=>nil}>]>, <kd:dd nil {:location=>2} [<kd:blank "\n" nil>, <kd:p nil {:location=>3} [<kd:text "para" nil {:location=>3}>]>]>]>]>

(note the <kd:blank "\n" nil>,) whereas the alternative with : ^ gets parsed to

=> <kd:root nil {:encoding=>#<Encoding:UTF-8>, :location=>1, :options=>{}, :abbrev_defs=>{}, :abbrev_attr=>{}} [<kd:dl nil {:location=>1, :ial=>nil} [<kd:dt nil {:location=>2, :raw_text=>"item"} [<kd:text "item" nil {:location=>nil}>]>, <kd:dd nil {:location=>2} [<kd:p nil {:location=>3} [<kd:text "para" nil {:location=>3}>]>]>]>]>

without <kd:blank>.

So, for beauty we might want to patch the parser to remove initial <kd:blank> from <kd:dd> elements (and <kd:li>, see below). And for robustness we might want to patch the kramdown output converter such that it handles blanks followed by paragraphs correctly in :dd (and :li) elements. One of those would suffice, but both would be better.

@ccorn
Copy link
Contributor Author

ccorn commented Jan 8, 2018

Hmm, the same issue occurs with other list types:

$ kramdown <<EOF
$ * 
$ 
$     para
$ EOF
<ul>
  <li>

    <p>para</p>
  </li>
</ul>
$ kramdown -o kramdown <<EOF 
$ * 
$ 
$     para
$ EOF
* para

$ kramdown -o kramdown <<EOF | kramdown
$ * 
$ 
$     para
$ EOF
<ul>
  <li>para</li>
</ul>

Note that there is a (horizontal) blank required after the asterisk.
Same with 1. instead of *.

@ccorn ccorn changed the title text-to-kramdown-to-HTML discrepancy for dd with initial blank line text-to-kramdown-to-HTML discrepancy for dd,li with initial blank line Jan 8, 2018
@gettalong gettalong added the bug label Feb 3, 2018
@gettalong gettalong self-assigned this Feb 3, 2018
@gettalong
Copy link
Owner

Hmm... I would consider this a bug in the parser. According to the syntax documentation for (un)ordered lists, the first paragraph should only be a real paragraph if its text is followed by a blank line. Similar for definition lists although there the blank line must precede the definition text.

I have a fix that I need to test a bit more.

And there is probably also a bug in the kramdown converter when outputting list items of ul/ol or definitions of dl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants