NAME
String::Tagged::Markdown::HFM
- parse and emit text with HedgeDoc Flavoured Markdown
SYNOPSIS
use String::Tagged::Markdown::HFM;
my $st = String::Tagged::Markdown::HFM->parse_markdown( $markdown );
# Conforms to the String::Tagged::Formatting API
String::Tagged::Terminal->new_from_formatting(
$st->as_formatting
)->say_to_terminal;
DESCRIPTION
This subclass of String::Tagged::Markdown handles all of the Markdown syntax recognised by the base class, and in addition the inline span marker extensions that are recognised by HedgeDoc Flavoured Markdown, the version of Markdown used on https://hedgedoc.org.
TAGS
This module adds the following extra tags.
superscript, subscript, underline, highlight
Boolean values indicating superscript, subscript, underline or highlight. These are parsed from
^superscript^
~subscript~
++underline++
==highlight==
METHODS
as_formatting
$fmt = $st->as_formatting( %args );
Returns a new String::Tagged
instance tagged with String::Tagged::Formatting standard tags.
By default the highlight
tag is not handled, but optionally the caller can specify how to handle it by setting a callback in the convert_tags
argument.
$st->as_formatting(
convert_tags => { highlight => sub { ... } }
);
Alternatively, this can be handled automatically by providing a colour to be set as the value of the bg
tag - either by passing the highlight_colour
named argument, or setting the value of the package-global $HIGHLIGHT_COLOUR
. Remember that this should be an instance of Convert::Color.
$st->as_formatting(
highlight_colour => Convert::Color->new( "vga:yellow" )
);
new_from_formatting
$st = String::Tagged::Markdown::HFM->new_from_formatting( $fmt, %args );
Returns a new instance by converting String::Tagged::Formatting standard tags.
By default the highlight
tag is not generated, but optionally the caller can specify how to generate it by setting a callback in the convert_tags
argument, perhaps by inspecting the background colour.
String::Tagged::Markdown::HFM->new_from_formatting( $orig,
convert_tags => { bg => sub ($k, $v) { ... } }
);
Alternatively, this can be handled automatically by providing a colour to be matched against the bg
tag - either by passing the highlight_colour
named argument, or setting the value of the package-global $HIGHLIGHT_COLOUR
. Remember that this should be an instance of Convert::Color. If the value of the bg
is within 5% of this colour, the highlight
tag will be applied.
String::Tagged::Markdown::HFM->new_from_formatting( $orig,
highlight_colour => Convert::Color->new( "vga:yellow" )
);
AUTHOR
Paul Evans <leonerd@leonerd.org.uk>