[Po4a-devel] parsing asciidoc styles

Anders Nawroth anders at neotechnology.com
Thu Sep 27 13:02:31 UTC 2012


Oops, I found a few more:

sect1, sect2, sect3, sect4
preface, colophon, dedication, synopsis, index

Seems a lot of different things in AsciiDoc share the same syntax,
these are called "section templates" (there's a few more already in our lists):
http://www.methods.co.nz/asciidoc/userguide.html#X93
Other uses are "paragraph styles" and "filters".

For the case with additional attributes, they are supported for verse
and quote, filtered out like so:
             ($line =~ m/^\[(verse|quote), +(.*)\]$/)) {

To try it out I went with this text (as both original and translation):
[verse, "William Blake", "from Auguries of Innocence"]
To see a world in a grain of sand,
And a heaven in a wild flower,
Hold infinity in the palm of your hand,
And eternity in an hour.

Which outputs the following into the po file:
#. type: verse
#: target/original/src/dummy.asciidoc:4
#, fuzzy, no-wrap
msgid "\"William Blake\", \"from Auguries of Innocence\""
msgstr "\"William Blake\", \"from Auguries of Innocence\""

#. type: verse
#: target/original/src/dummy.asciidoc:9
#, fuzzy, no-wrap
msgid ""
"To see a world in a grain of sand,\n"
"And a heaven in a wild flower,\n"
"Hold infinity in the palm of your hand,\n"
"And eternity in an hour.\n"
msgstr ""
"To see a world in a grain of sand,\n"
"And a heaven in a wild flower,\n"
"Hold infinity in the palm of your hand,\n"
"And eternity in an hour.\n"

I think this is good enough, but should be expanded to cover all styles in
$asciidoc_RE_STYLE_PARAGRAPH and $asciidoc_RE_STYLE_LIST.
And a user contributed list of styles/filters, I guess? (including the
different wrapping modes)

I'm currently fixing a problem with the current verse/quote +
attributes code ...
I'll report back regarding that soon.

/anders



More information about the Po4a-devel mailing list