#1455 Enable markdown extensions
Closed: Fixed 7 years ago Opened 7 years ago by tibbs.

To bring things over from #1349:

python-markdown (even in el7) provides a set of extensions which are in the source, supported and considered stable, but not enabled by default. At first glance, these look to be very useful to pagure:

  • abbreviations
  • admonition
  • attribute lists
  • codehilite (which makes use of pygments, so it might be more complicated
  • definition lists
  • fenced code
  • footnotes
  • sane lists
  • smart strong
  • table of contents.

Some of those are also included in the "extra" meta-extension, which I believe exists to provide a set of features provided by some PHP-related markup package.


I'm pretty sure all that's necessary to add most of these extensions (maybe not codehilite) is to add the extensions to the list in lib/init.py:text2markdown()

But I still don't have a test instance spun up so I can't do any useful testing, and I'd like to know if this is something you'd like to pursue before investing the time and sending a PR.

You are right, enabling these extensions was quite straight forward, for the moment I propose turning on:

        'markdown.extensions.extra',
        'markdown.extensions.nl2br',
        'markdown.extensions.toc',

For the record, extras includes:

  • Abbreviations
  • Attribute Lists
  • Definition Lists
  • Fenced Code Blocks
  • Footnotes
  • Tables
  • Smart Strong

Added:

  • admonition
  • codehilite (with the corresponding CSS)
  • sane_lists

Do we want others?

I'm thinking at this point it might be better to let it all shake out a bit. We also need something that actually explains all of this, since the link at the bottom of the comment entry box doesn't really cover it.

Of the other basic extensions:

  • HeaderID - deprecated, replaced by TOC which is enabled.
  • MetaData - I don't see the utility of this without some special pagure support for it. But with that support, there are some interesting possibilities like providing metadata for ticket template files and such, or letting you set ticket metadata directly in the comment.
  • SmartyPants - I don't really see the point. This would probably confuse more than it would help.
  • WikiLinks - This could be useful to link between document files in a docs repo or something.

Thinking more about MetaData, I can see some utility for adding

Pagure-Action: close
or something like that to the top of the ticket and having pagure do something with it. Especially if you're replying to an email.

And in case it isn't immediately obvious, with the MetaData extension, the markdown parser gives you a hash of the metadata bits it got from the document. Of course, you can just parse the document for that kind of thing in a separate pass; pagure probably already does. Using the markdown-provided mechanism does seem like an interesting possibility, though.

Also, other extensions can use the metadata parsed by this extension for various things. At least the stock WikiLinks extension can use it.

The metadata disappears completely from the formatted document, though I guess another extension could trivially format it if that would be desirable.

@pingou changed the status to Closed

7 years ago

Adding nl2br breaks display of my README.md file. Is there any way to avoid these line breaks, short of putting the entire paragraph on one line?

Login to comment on this ticket.

Metadata