There are several types of plain text structuring / formatting syntax out there, for example:
- MarkDown
- MediaWiki
- XWiki
- HTML
Is there a generic tool (easier / more appropriate than reg-ex) that helps defining and executing conversion rules?
There are several types of plain text structuring / formatting syntax out there, for example:
Is there a generic tool (easier / more appropriate than reg-ex) that helps defining and executing conversion rules?
Pandoc (License: GPL) can import:
and convert to these and various other formats. (Custom formats can be added with Lua.)
It’s a standalone command-line program and comes with a Haskell library.
You can test it online: http://johnmacfarlane.net/pandoc/try/
With txt2tags (https://txt2tags.org/), you can export to at least 20 different formats, including rtf (rich text format), latex, html, wikipedia, creole, dokuwiki, restructured text, markdown, spip, AsciiDoc...
There is an html importer for txt2tags (https://wiki.txt2tags.org/index.php/Main/Html2wiki) so you can do pretty everything with it.
(edit) To be more complete in my answser, yes I'm using txt2tags for several years (at least 7 or 8).
The only drawback I can think of is it's less known than for example markdown, but it's older (since 2001) and in my opinion better (more customisable, more extendable, more logicial and not fragmented in its syntax).
It has a python 2 implementation for all the exports mentionned above, and a php implementation for html export only.
You can create special export rules either with a new syntax definition module, or with regex. For the first, it is quite easy, for example here is the export rule for bold in the html module:
'fontBoldOpen' : '<B>' ,
'fontBoldClose' : '</B>' ,
With regex, you can do it in your document or as a configuration file.
For exemple, to use strong instead of b in your html output, you can create this rule:
%!postproc: '<b>' '<strong>'
%!postproc: '</b>' '</strong>'