Martin Tithonium (tithonium) wrote,
Martin Tithonium

Insane? why yes, yes I am.

$text =~ s!^\s*\*\s*(.+)$!<li>$1</li>!gm;
$text =~ s!<li>!<ul>\n<li>!s;
$text =~ s!(.*</li>)!$1\n</ul>!s;

$text =~ s!(?<=\s)\*(\S[^\*]+?\S)\*(?=\s)!<b>$1</b>!gs;
$text =~ s!(?<=\s)/(\S[^\*]+?\S)/(?=\s)!<i>$1</i>!gs;
$text =~ s^(?<!>)(\r\n|\n|\r)^<br />$1^gs;

All so that things like

la la la /but/ la la *then* la la
* foo

can become

la la la but la la then la la
  • foo
  • foo

And I refuse to implement Markdown or anything like that for this. And because XML::Simple is too dumb to let me say "never parse the contents of tags named <text>".

edit: also, one of these days I might actually remember how to write zero-width negative look-behinds, so I don't have to keep looking it up. But not yet.
  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded