Text::...scount(3pm)

πŸ’– Text::...scount β€” like, the manual page, but make it make sense πŸ’–

okay bestie, gather round, because this one is genuinely iconic. it's Text::Markdown::Discount, from the User Contributed Perl Documentation corner of the universe, and it is fast.


✨ NAME ✨

Text::Markdown::Discount β€” a fast function for converting markdown to HTML (and yeah, it requires a C compiler, no cap πŸ”₯)


🌸 SYNOPSIS 🌸

use Text::Markdown::Discount;
my $html = markdown($text)

that's it. that's the whole vibe. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

So Text::Markdown::Discount is a perl interface to the "Discount" library, which is a C implementation of John Gruber's "markdown". C! as in, compiled! as in, fast! 🏎️✨

It is the fastest of the Perl modules available for converting markdown β€” go look at the list in SEE ALSO if you don't believe me. And it passes Gruber's Markdown testsuite, which is the academic validation of the markdown world. πŸŽ“

Given that the performance of Discount is what it is, Text::Markdown::Discount processes markdown formatted text quickly and passes the Markdown test suite at <http://daringfireball.net/projects/downloads/MarkdownTest_1.0.zip>. Look at her go. πŸ‘‘

⚠️ Important bestie warning: the interface of the markdown() function in this module is not compatible with the markdown() function in Text::Markdown. Like, they are not the same girl. Do not assume. πŸ™ˆ

πŸŽ€ EXPORT πŸŽ€

markdown is exported by default. she just shows up. she's already in the group chat. πŸ’–


πŸ’œ FUNCTION πŸ’œ

Text::Markdown::Discount::with_html5_tags()

This function enables html5 block-level elements support. πŸŽ‰

Once you call it, Text::Markdown::Discount::markdown() will handle these html5 tags as block elements:

  • aside
  • footer
  • header
  • hgroup
  • nav
  • section
  • article
πŸ’€ NOTE: There is no way to disable/re-enable this feature in one process right now. So like... it's a one-way door. Choose wisely. πŸšͺ✨

Here's the little demo, verbatim:

use Text::Markdown::Discount;
Text::Markdown::Discount::with_html5_tags();
my $html = markdown('<article>content</article>');
#
# In $html, <article> tag won't be wrapped with <p> tag

see how the <article> tag won't be wrapped with a <p> tag? she's free. she's living her truth. πŸ¦‹


🌈 SEE ALSO 🌈

There are other modules on CPAN for converting Markdown, if you're into that:

  • Text::Markdown is a pure-perl markdown converter. (pure perl! no C compiler required! slower but unbothered. πŸ’…)
  • Markdent is a toolkit for parsing markdown, which can also be used to convert markdown to HTML.
  • Text::Markup is a converter than can handle a number of input formats, including markdown.
  • Text::MultiMarkdown converts MultiMarkdown (a superset of the original markdown format) to HTML.

Additional markdown resources, for the girlies who want lore:


πŸ‘‘ AUTHOR πŸ‘‘

Masayoshi Sekimura, <sekimura@cpan.org>


Copyright (C) 2013 by Masayoshi Sekimura

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available. πŸŽ€ (free software!! we love to see it!!)

This product includes software developed by David Loren Parsons <http://www.pell.portland.or.us/~orc>


and that's the whole page, bestie. this was perl v5.40.0, dated 2025-02-02 β€” thanks for reading, mwah, go convert some markdown, ily πŸ“πŸ§šπŸ’œ

πŸ“¦ where this page comes from