NAME

Text::AsciidocDown::Subs - Attribute substitution and inline formatting

SYNOPSIS

use Text::AsciidocDown::Subs;

my $attrs = Text::AsciidocDown::Subs::build_attributes(\%runtime);
my $text  = Text::AsciidocDown::Subs::apply_normal_subs($input, $attrs);

DESCRIPTION

This module provides attribute building, attribute reference substitution, and inline formatting/macro expansion for Text::AsciidocDown. It is not intended for direct use; callers should use the OO interface provided by Text::AsciidocDown.

INTERFACE

build_attributes

my $attrs = Text::AsciidocDown::Subs::build_attributes(\%runtime);

Builds a complete attribute hash from runtime attributes, adding built-in defaults (empty, idprefix, idseparator, nbsp, quotes, quotes-single, sp, vbar, zwsp, and Markdown-specific attributes).

The quotes and quotes-single attributes

AsciiDoc's paired quote syntax has two forms: "`text`" (double-quoted) and '`text`' (single-quoted). This module maps them to two independently configurable attributes:

quotes          # governs "`text`", default open/close: U+201C U+201D
quotes-single   # governs '`text`', default open/close: U+2018 U+2019

Each attribute is a space-separated open/close pair, e.g.:

:quotes: <q> </q>
:quotes-single: <q> </q>

This differs from downdoc, which uses a single quotes attribute (default <q> </q>) for both forms, so '`x`' and "`y`' are indistinguishable in its output. Real curly Unicode characters were chosen as the default here instead of downdoc's raw <q></q> HTML because they are what a paired AsciiDoc-to-Markdown-to-AsciiDoc round trip through Text::MarkdownAdoc actually stabilises on: that module maps U+201C/U+201D and U+2018/U+2019 straight back to these exact AsciiDoc forms, whereas raw <q> HTML is unknown to it and gets re-escaped as passthrough on every pass. Callers who want the old downdoc-parity behavior (both forms sharing <q></q>) can set both attributes explicitly.

substitute_attributes

my $text = Text::AsciidocDown::Subs::substitute_attributes($text, $attrs);

Substitutes {name} attribute references in the text with their values.

apply_normal_subs

my $text = Text::AsciidocDown::Subs::apply_normal_subs($text, $attrs);

Applies the full normal substitution chain:

  • Stash inline AsciiDoc passthrough (+++text+++) so it survives completely unprocessed and is restored verbatim at the end

  • Escape < outside monospace

  • Apply AsciiDoc quotes ("`text`" via quotes, '`text`' via quotes-single)

  • Inline formatting (bold, emphasis, monospace, mark, strikethrough, standalone curly-quote markers)

  • Attribute substitution

  • Macros (anchors, images, links, xrefs)

  • Curly apostrophe conversion

block_image_to_markdown

my $md = Text::AsciidocDown::Subs::block_image_to_markdown($line, $attrs);

Converts a block image macro (image::[]) to Markdown if the line matches.

image_to_markdown

my $md = Text::AsciidocDown::Subs::image_to_markdown($target, $attrlist, $attrs);

Converts an image macro to Markdown ![]() syntax.

escape_lt_outside_monospace

my $text = Text::AsciidocDown::Subs::escape_lt_outside_monospace($text);

Escapes angle brackets to HTML entities while preserving xref shortcuts.

AUTHOR

Sandor Patocs

LICENSE

Same terms as Perl itself.