I have a text translation problem to solve. That is, I want to take some text with simple markup and produce other text in another form of markup. The original text looks something like this:
HEAD: LAMP Post
DECK: Burn the Bulb Brighter
AUTHOR: Joe Smith
This is I<some> sample text. It uses a few pieces of markup such as C<
+courier>, C<I<courier italics>>, B<bold>, and I<italics.>
Some time there is
C<
long
sections of code
>
or
I<
Long quotes
that appears in blocks
>
There can also be figures, such as I<Figure One.>
[ BEGIN FIGURE ONE: This is a caption with I<italics> ]
[ INSERT sample.jpg ]
[ END FIGURE ONE ]
Etc.
BIO: John Smith
For sake of discussion, imagine I want to produce HTML (but I also want to be able to produce Quark and InDesign markup, too). I definitely want to maintain a map of original tags to new tags, and have that list be dynamic so I can emit a variety of formats.
I have something working with Parse::RecDescent. I chose it because of the possibility of embedded tags, such as C<I<courier italics.>> However, I am wondering if there is some other module I should consider using? Text::Balanced? A modified HTML parser?
Suggestions?
Martin
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.