gjtorikian / commonmarker

Ruby wrapper for the comrak (CommonMark parser) Rust crate
MIT License
416 stars 80 forks source link

Description lists not working #216

Closed DannyBen closed 1 year ago

DannyBen commented 1 year ago

I am assuming the Description Lists extension actually means Definition Lists - I am unable to make it work.

On a side note, perhaps the option key should be renamed to definition_lists regardless of how comark calls it?

This code does not produce the expected <dl> <dt> tags

require 'bundler/inline'
gemfile { gem 'commonmarker', '1.0.0.pre6' }

markdown = <<~MARKDOWN
  ~strikethrogh disabled to ensure options accepted~

  Commonmark Definition
  : Ruby wrapper for comrak (CommonMark parser)
MARKDOWN

extensions = { strikethrough: false,  description_lists: true }
options = { extension: extensions, render: { hardbreaks: false } }
output = Commonmarker.to_html markdown, options: options
puts output

Output:

<p>~strikethrogh disabled to ensure options accepted~</p>
<p>Commonmark Definition
: Ruby wrapper for comrak (CommonMark parser)</p>
gjtorikian commented 1 year ago

Ah, comrak calls it definition lists: https://github.com/kivikakk/comrak#extensions

I just made the typo here: https://github.com/gjtorikian/commonmarker/blob/46631023e93466af7aa360cf821ac7b120af47fc/ext/commonmarker/src/options.rs#L100-L102

Thanks for the report, will fix it soon.

gjtorikian commented 1 year ago

Ah, actually, I believe this is working as expected.

First, MDN calls dls description lists as well: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dl

Second, your markdown has an error: there needs to be a paragraph between the term and its definition:

    markdown = <<~MARKDOWN
      ~strikethrogh disabled to ensure options accepted~

      Commonmark Definition

      : Ruby wrapper for comrak (CommonMark parser)
    MARKDOWN

I'll keep the option name as description_lists.

DannyBen commented 1 year ago

Closing the issues prematurely hints that you are not interested in any input. If I am wasting my time trying to improve this gem, let me know please.

Second, your markdown has an error: there needs to be a paragraph between the term and its definition:

This statement is wrong.

  1. All specs show it without a newline.
  2. It does not make sense for it to have a new line, since the title and description are the same item.
  3. It is intentionally designed like this, so that renderers that do not support it will simply show it as one paragraph having "Title : Definition".

The first 4 references I found:

gjtorikian commented 1 year ago

Closing the issues prematurely hints that you are not interested in any input. If I am wasting my time trying to improve this gem, let me know please.

You are not wasting your time. Keeping issues open indefinitely stagnates the project. As I have no idea when you'll come back and chastize me or comment or whatever. It helps me know the health of the project: open there's work to do, closed there isn't.

The first 4 references I found:

You can find as many references as you want, it doesn't matter if the underlying project (comrak) doesn't support it. From their docs:

Each term must be defined in one paragraph, followed by a blank line, and then by the details. Details begins with a colon.

All specs show it without a newline.

Which specs?