NAME

Markdown::Parser::Code - Markdown Code Element

SYNOPSIS

my $o = Markdown::Parser::Code->new;
# or
$doc->add_element( $o->create_code( @_ ) );

VERSION

v0.3.0

DESCRIPTION

This class represents a code formatting. It is used by Markdown::Parser and inherits from Markdown::Parser::Element

METHODS

as_markdown

Returns a string representation of the code formatted in markdown.

It returns a plain string.

as_pod

Returns a string representation of the code formatted in pod.

It returns a plain string.

as_string

Returns an html representation of the code.

It returns a plain string.

add_element

Provided with a Markdown::Parser::Text object, and this adds it as content element of this class.

Upon adding the text data, it does some encoding on characters <, > and &

class

Sets or gets the array of css class associated with this code.

Values are stored as a Module::Generic::Array object.

css_rsrc

Sets or gets an array reference of css stylesheet url used for css highlighting.

This defaults to https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.2/styles/default.min.css|

fenced

Takes a boolean value, i.e. 1 or 0 to indicate whether this code is fenced or not.

When the value is true, the markdown representation of the code will use ``` before and after the code as delimiter.

highlight

Boolean value that serves to decide on the use of JavaScript code highlighter.

When set to true, this will add a <link> and <script> tags in the document head pointing to the CDN (Content Delivery Network) to load the necessary resources.

<link rel="stylesheet"
      href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.2/styles/default.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.2/highlight.min.js"></script>

And you can add extra script to load for additional languages, for example:

<script charset="UTF-8"
 src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.2/languages/go.min.js"></script>

According to "highlight" documentation, the default bundle contains 38 languages.

id

Sets or gets the array of id class associated with this code. Normally there should only be one.

Values are stored as a Module::Generic::Array object.

inline

Takes a boolean value, i.e. 1 or 0 to indicate whether this code is inline or not.

js_data

Sets or gets the javascript code to use.

This defaults to:

hljs.initHighlightingOnLoad();

js_rsrc

Sets or gets an array reference of javascript url used for code highlighting.

This defaults to https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.2/highlight.min.js

SEE ALSO

Markdown original author reference on emphasis: https://daringfireball.net/projects/markdown/syntax#em

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.