Marked: Add support for description lists

Created on 25 Sep 2013  路  7Comments  路  Source: markedjs/marked

http://kramdown.rubyforge.org/syntax.html#definition-lists

(In html4 it was called definition list, in html5 its called description list)

All 7 comments

Would you guys accept a pull request for this?

+1, can just be accessible as a default renderer method.

For reference: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dl
This is a standard HTML element.

Any luck?

+1

We just used this to solve our problem, similar to the way he does it here for Headings :-

var renderer = new marked.Renderer();
  renderer.paragraph = function (text) {
    var dlTest = /(^|\n\n+)(\S.+)(\n\:(\s{4,}|\t))(\S.+)/

    var dl = '\n\n' +
      '<dl>' +
      '<dt><p>$2</p></dt>' +
      '<dd><p>$5</p></dd>' +
      '</dl>' +
      '\n\n';

    if (text.match(dlTest)) {
      text = text.replace(dlTest, dl);
      return text;
    } else {
      return '<p>' + text + '</p>\n';
    }
  };

It's not perfect, as the <dl> tags get duplicated around each row / definition in the list, but we were happy with the result.

+1 I find that definition lists are incredibly useful!

+1

We are currently targeting two Markdown specifications. If you can find where the syntax of these two specifications allow dl, please open a new issue with this reference. See #956 - Thank you.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cusalvi picture cusalvi  路  3Comments

raguay picture raguay  路  4Comments

learykara picture learykara  路  3Comments

chunhei2008 picture chunhei2008  路  3Comments

bennycode picture bennycode  路  4Comments