Text::...onMark(3pm)
π Text::Markup::CommonMark β the manual, but make it cute π
okay bestie, gather round, because we're talking about Text::Markup::CommonMark (that's the page you're on, Text::...onMark(3pm) if we're being formal, which we are not) β it's the CommonMark Markdown parser for Text::Markup. no cap. let's go π¦
β¨ NAME β¨
Text::Markup::CommonMark β a CommonMark Markdown parser for Text::Markup. she's a parser, she's a baddie, she's here to turn your .md files into HTML. periodt π
π SYNOPSIS π
use Text::Markup::CommonMark;
my $html = Text::Markup->new->parse(file => 'README.md');
my $raw = Text::Markup->new->parse(
file => 'README.md',
options => [ raw => 1 ],
);
look at her go. two lines and you've got HTML. main character energy fr fr β¨
πΈ DESCRIPTION πΈ
This is the CommonMark parser for Text::Markup β like, the actual CommonMark spec, the one at <https://commonmark.org>. On load, it replaces the default Text::Markup::Markdown parser for parsing Markdown (the classic one, <https://daringfireball.net/projects/markdown/>). π«Ά
β οΈ okay important: Text::Markup does not load this module by default. but the moment you load it manually, it becomes the preferred Markdown parser. it's giving "I didn't ask to be here but I'm running the show now." π
Text::Markup::CommonMark reads in the file (relying on a BOM, <https://www.unicode.org/unicode/faq/utf_bom.html#BOM>), hands it off to CommonMark for parsing, and then returns the generated HTML as an encoded UTF-8 string with an "http-equiv="Content-Type"" element identifying the encoding as UTF-8. so clean. so UTF-8. obsessed. ππ
π¦ the extensions she recognizes
It recognizes files with the following extensions as CommonMark Markdown:
.md.mkd.mkdn.mdown.markdown
π changing which files she claims
To change it the files it recognizes, load this module directly and pass a regular expression matching the desired extension(s), like so:
use Text::Markup::CommonMark qr{markd?};
she's flexible like that π
π raw output mode
Normally this module returns the output wrapped in a minimal HTML document skeleton. If you would like the raw output without the skeleton, you can pass the "raw" option to "parse". no skeleton, just vibes. π
β the options (yes, all of them)
In addition Text::CommonMark supports all of the CommonMark parse options and render options, including:
"smart"β When true, convert straight quotes to curly,---to em dashes,--to en dashes. Enabled by default. she's fancy like that β¨"sourcepos"β When true, include adata-sourceposattribute on all block elements. Disabled by default."hardbreaks"β When true, render soft-break elements as hard line breaks. Disabled by default."nobreaks"β When true, render soft-break elements as spaces. Disabled by default."validate_utf8"β When true, validate UTF-8 in the input before parsing, replacing illegal sequences with the replacement character"U+FFFD". Disabled by default. she's checking ur vibes, literally π§"unsafe"β Render raw HTML and unsafe links ("javascript:","vbscript:","file:", and"data:", except for"image/png","image/gif","image/jpeg", or"image/webp"mime types). Raw HTML is replaced by a placeholder HTML comment. Unsafe links are replaced by empty strings. Enabled by default.
π¨ bestie, look at that word: unsafe. it's called that for a reason. this one is enabled by default, and it renders raw HTML and those links on purpose. know what you're turning on, okay? π«Ά
π AUTHOR π
David E. Wheeler <david@justatheory.com>
iconic. we stan. π
π COPYRIGHT AND LICENSE π
Copyright (c) 2011-2025 David E. Wheeler. Some Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
and that's the whole page, bestie πΈ this was perl v5.40.1, dated 2025-12-18, brought to you by the User Contributed Perl Documentation. go forth and parse. slay. πβ¨π¦
π¦ where this page comes from
- ubuntu resolute: libtext-markup-perl 0.41-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtext-markup-perl 0.41-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms