#!/usr/bin/php
\n";
break;
case 'TD':
case 'TD2':
case 'TH':
case 'TH2':
print "\n";
break;
case 'ULIST':
case 'ULIST2':
print "\n";
break;
}
}
function decode_string(string $string) : string
{
$decoded_str = '';
$skip = 0;
for ($ii = 0; $ii < strlen($string); $ii++) {
if ($skip) {
# Skip over HTML codes and tags
$skip--;
continue;
}
if ($string[$ii] == '&') {
# Replace '&' with &, but don't change HTML codes such as
# to .
$codes = array('-', '✓', '&', 'ε', '>', '<',
'—', ' ', '–');
$found = False;
foreach ($codes as $code) {
if (substr($string, $ii, strlen($code)) == $code) {
$decoded_str .= $code;
$skip = strlen($code) - 1;
$found = True;
break;
}
}
if ($found) {
continue;
}
$decoded_str .= '&';
}
else if ($string[$ii] == '<') {
# Replace '<' with <, but don't change HTML tags such as
# to <br>.
$tags = array('
',
'', '
',
'', '',
'', '',
'', '',
'', '',
'
', '
', '', '', '', '', '', '', '', '', ); $found = False; foreach ($tags as $tag) { if (substr($string, $ii, strlen($tag)) == $tag) { $decoded_str .= $tag; $skip = strlen($tag) - 1; $found = True; break; } } if ($found) { continue; } $decoded_str .= '<'; } else if ($string[$ii] == '>') { $decoded_str .= '>'; } else { $decoded_str .= $string[$ii]; } } return $decoded_str; } function get_state(string $line) : bool { global $document_head, $in_css, $in_table, $paragraph_num, $state; switch ($line) { case '---': close_tags(); $state = 'NO_OP'; return True; case '---body': if ($in_css) { print "\n"; $in_css = False; } if (!$document_head) { print "\n\n"; $document_head = True; } $state = 'NO_OP'; return True; case '---br': assert_head(); # ---br does not close tags or change state, so table rows and tables # have to be explicitly closed. if ($in_table) { print "\n\n"; $in_table = False; $state = 'NO_OP'; } print "