1

Topic: Using htmLawed in non-PHP scripts

htmLawed can, of course, be used in non-PHP scripts through system calls invoking PHP. This is an example showing capturing the htmLawed-processed text in the stdout stream.

Create a PHP file (say 'filter.php') with code like:

<?php
include('path/to/htmLawed.php');
eval('$argv[2] = '. $argv[2]. ';');
fwrite(STDOUT, htmLawed($argv[1], $argv[2], $argv[3]));
exit(0);

'filter.php' is passed htmLawed's three arguments -- input text, config and spec -- and invoked using appropriate code. E.g., in Python:

text = 'input to be processed'
config = 'array("safe"=>1)'
spec = 'a=-*, href, title'
p = os.popen('php filter.php ' + text + ' ' + config + ' ' + spec)