NAME
Markdown::Parser::Footnote - Markdown Footnote Element
SYNOPSIS
my $o = Markdown::Parser::Footnote->new;
# or
$doc->add_element( $o->create_footnote( @_ ) );
VERSION
v0.3.0
DESCRIPTION
This class represents a footnote. It is used by Markdown::Parser and inherits from Markdown::Parser::Element
This is an extension of the original Markdown.
To quote from Markdown Guide:
Footnotes allow you to add notes and references without cluttering the body of the document. When you create a footnote, a superscript number with a link appears where you added the footnote reference. Readers can click the link to jump to the content of the footnote at the bottom of the page.
To create a footnote reference, add a caret and an identifier inside brackets ([^1]). Identifiers can be numbers or words, but they can’t contain spaces or tabs. Identifiers only correlate the footnote reference with the footnote itself — in the output, footnotes are numbered sequentially.
Add the footnote using another caret and number inside brackets with a colon and text ([^1]: My footnote.). You don’t have to put footnotes at the end of the document. You can put them anywhere except inside other elements like lists, block quotes, and tables.
Here's a simple footnote,[^1] and here's a longer one.[^bignote]
[^1]: This is the first footnote.
[^bignote]: Here's one with multiple paragraphs and code.
Indent paragraphs to include them in the footnote.
`{ my code }`
Add as many paragraphs as you like.
The rendered output looks like this:
Here’s a simple footnote,1 and here’s a longer one.2
1. This is the first footnote. ↩
2. Here’s one with multiple paragraphs and code.
Indent paragraphs to include them in the footnote.
{ my code }
Add as many paragraphs as you like. ↩
Inline Footnotes
For consistency with links, footnotes can be added inline, like this:
I met Jack [^jack](Co-founder of Angels, Inc) at the meet-up.
Inline notes will work even without the identifier. For example:
I met Jack [^](Co-founder of Angels, Inc) at the meet-up.
However, in compliance with pandoc footnotes style, inline footnotes can also be added like this:
Here is an inline note.^[Inlines notes are easier to write, since
you don't have to pick an identifier and move down to type the
note.]
The footnote id of inline notes will be auto-generated
Footnotes will appear at the end of the document in their order of appearance.
METHODS
add_reference
Provided with an Mardown::Parser::FootnoteReference object and this will add the object to the array of footnote reference objects.
See "references"
as_markdown
Returns a string representation of the footnote formatted in markdown.
It returns a plain string.
as_pod
Returns a string representation of the footnote formatted in pod.
It returns a plain string.
as_string
Returns an html representation of the footnote.
It returns a plain string.
references
Access the array object of Markdown::Parser::FootnoteReference objects used for backlinks, i.e. the origin for this footnote. It is used to create a link reference back to the location that reference this footnote, by using the object id.
This is used to create a link back to the original footnote reference.
Note that there may be multiple footnote reference for one footnote.
id
Sets or gets the id of the footnote. The value is stored as an Module::Generic::Scalar object.
This id is set arbitrarily by the user and must be unique and is used to form a link reference to this footnote.
parse
Parse the footnote data and returns the current object.
text
Sets or gets the content of this footnote.
If a text value is provided, it will be stored as a child element of the footnote as a Markdown::Parser::Text object.
You can also add directly element like this:
$footnote->add_element( $top->create_paragraph )
unparsed
Sets or gets the unparsed version of the footnotes.
SEE ALSO
https://www.markdownguide.org/extended-syntax#footnotes, https://pandoc.org/MANUAL.html#footnotes, https://stackoverflow.com/questions/15110479/markdown-and-footnotes-most-natural-format-missing
AUTHOR
Jacques Deguest <jack@deguest.jp>
COPYRIGHT & LICENSE
Copyright (c) 2020 DEGUEST Pte. Ltd.
You can use, copy, modify and redistribute this package and associated files under the same terms as Perl itself.