Plugin Request: Fancy Lists

I realize this might be a bit out of the blue, but I’ve put together a Discourse plugin to support fancy lists and if possible, I think it would be cool to install it here.

It’s just a thin wrapper around this markdown-it plugin (markdown-it is the Markdown parser used by Discourse). There’s a bit of bundling/compatibility workarounds explained in the README, but it works out to just a few lines of code — I’m happy to explain in more detail if there are concerns about maintainability, etc.

Use Cases

It always bugged me a little that lists in our laws aren’t properly parsed. Here’s an example of the generated HTML with this plugin installed:

Markdown source
# Markdown Act
*An act to test Markdown formatting*

# 1. Markdown

1. Markdown is a markup language for creating formatted text with a plain-text reader.

#. Discourse markdown syntax can be extended with plugins, such as to support lettered lists:
   a. List item 1
      i) Sub-item 1
      #) Sub-item 2
      #) Sub-item 3
   #. List item 2
   #. List item 3
Generated HTML

Markdown Act

An act to test Markdown formatting

1. Markdown

  1. Markdown is a markup language for creating formatted text with a plain-text reader.

  2. Discourse markdown syntax can be extended with plugins, such as to support lettered lists:

    1. List item 1
      1. Sub-item 1
      2. Sub-item 2
      3. Sub-item 3
    2. List item 2
    3. List item 3
HTML output without plugin

Markdown Act

An act to test Markdown formatting

1. Markdown

  1. Markdown is a markup language for creating formatted text with a plain-text reader.

#. Discourse markdown syntax can be extended with plugins, such as to support lettered lists:
a. List item 1
i) Sub-item 1
#) Sub-item 2
#) Sub-item 3
#. List item 2
#. List item 3

It’s also just useful if anybody wants to have lettered lists, roman numeral lists, or lists that don’t start at 1 (or a, or i).

For more detailed information on supported syntax, you can check out the supported syntax for the markdown-it plugin that this is based on.

Compatibility

I’ve tested this plugin on a local instance of Discourse (used to generate the example above). It seems to work fine in the generated HTML and in the client-side preview. I haven’t installed all plugins/theme components we have here, so I don’t know if any conflict, but I don’t think they should?

Alternatives

Of course I found it only after putting my own plugin together (I mean, even Googling the name verbatim doesn’t turn it up…), but apparently someone else has done the same thing before.

I haven’t tested it (and I think ol[start=*] would need to be added to the allow list to support lists not starting at 1?) but it’s based on the same markdown-it plugin, released under the MIT license as well, etc.

2 Likes

This looks good, I’ll see about adding it later today.

2 Likes

This is now installed

Markdown Act

An act to test Markdown formatting

1. Markdown

  1. Markdown is a markup language for creating formatted text with a plain-text reader.

  2. Discourse markdown syntax can be extended with plugins, such as to support lettered lists:

    1. List item 1
      1. Sub-item 1
      2. Sub-item 2
      3. Sub-item 3
    2. List item 2
    3. List item 3
1 Like

Thanks! Looks sweet… if I may say so myself… :stuck_out_tongue: