Utility class for encoding and decoding markup delimiters in content and attributes.

Gets customized for a given target markup language (such as HTML or XML) via the output_format configuration property.

Constructor

new Markupencoder()

Name Description
configure Configuration method.
decode_attribute Inverse of encode_attributes().
decode_content Inverse of encode_content().
decode_markdown Inverse of decode_markdown()
encode_attribute Encodes characters not permitted in attributes into character entity references.
encode_content Encodes characters not permitted in HTML/XML content into character entity references.
encode_markdown Returns text with span-level markdown syntax tokens replaced by character entity references Note that backticks and double quotes are *not* replaced.
reset Resets internal state.

Member Details

configure(args)

Configuration method.

Parameters

Name Type Description
args Object.<string, string>

Map of configuration properties

decode_attribute(text): string

Inverse of encode_attributes().

Parameters

Name Type Description
text string

Returns

string
decode_content(text): string

Inverse of encode_content().

Parameters

Name Type Description
text string

Returns

string
decode_markdown(text, text): string

Inverse of decode_markdown()

Parameters

Name Type Description
text string
text string

Returns

  • string

    .

  • string
encode_attribute(text): string

Encodes characters not permitted in attributes into character entity references.

Eg. for HTML and XML, the characters <, >, and & get encoded.

Note that escaping < isn't strictly necessary by HTML and XML parsing rules.

Parameters

Name Type Description
text string

Returns

string
encode_content(text): string

Encodes characters not permitted in HTML/XML content into character entity references.

Eg. for HTML and XML, the characters <, >, and & get encoded.

Parameters

Name Type Description
text string

Returns

string
encode_markdown(text): string

Returns text with span-level markdown syntax tokens replaced by character entity references

Note that backticks and double quotes are not replaced.

Parameters

Name Type Description
text string

Returns

string
reset()

Resets internal state.