Un naufragio personal

Ángel Ortega

artemus - Text substitution tool and much more


 artemus -i|--input={input file} -o|--output={output file}
	[-c|--conf={config file}]
	[-m|--msdos] [-a|--append]


artemus is a text substitution tool (thought mainly for preprocessing HTML). Macros are defined in the file artemus.conf, in the form key=value, being value the destination text, that can have parameters. The macro is included in the source file between the {- and } marks. The (possible) parameters are delimited by the | symbol.


In artemus.conf file:

  1. some simple definitions Perl=<a href="http://www.perl.com">Perl</a> LWN=<a href="http://www.lwn.net">Linux Weekly News</a> separator=<br><hr><br> head=<html><body bgcolor=ffffff>
  1. definitions with parameters
  2. generic link link=<a href="http://$1">$0</a>
  3. generic meta meta=<meta name="$1" content="$0">
  4. link using the link macro CPAN={-link|CPAN|www.cpan.org}

In a source file index.artemus:

 {-meta|links, free software|keywords}

By running

 artemus -i index.artemus -o index.html

you obtain the file index.html:

 <html><body bgcolor=ffffff>
 <meta name="keywords" content="links, free software">
 <li><a href="http://www.perl.com">Perl</a>
 <li><a href="http://www.lwn.net">Linux Weekly News</a>
 <li><a href="http://www.cpan.org">CPAN</a>
 <li><a href="http://www.kernel.org">kernel.org</a>

The --paragraph argument let us define a string to substitute the empty lines in the document. If defined as <p>, you can create HTML documents separating the paragraphs with only a blank line, as artemus will fill them with <p>.

The --msdos argument creates the typical MSDOS end of line, CR+LF.

The --append argument appends the output to destination file, instead of overwriting it.


(C) Angel Ortega <angel@triptico.com> 2000/2008