Some of the PM tags are too long (blockquote), and it is much easier for emacs to generate angle-bracket tags than for me to remember the syntax for the id:// or cpan:// type tags.

So here we have a small set of substitutions which make it easy to write offline and convert to Perlmonks syntax and upload the conversion.

open I, shift or die "$!"; while (<I>) { /xml>/ and next; s/title>/h3>/g; s/bq>/blockquote>/g; # <bq> instead of <blockquote> s/introduction>/blockquote>/g; s!<cpan>(.*)</cpan>![cpan://$1]!g; # <cpan>mod::name</cpan> s!<c>!<code>!g; # <c>code</c> s!</c>!
!g; print; } </CODE>

Replies are listed 'Best First'.
Re: PMML - Perlmonks Markup Language
by trantor (Chaplain) on Sep 02, 2001 at 22:29 UTC

    You could make your converter stronger with a couple of fixes.

    Regular expressions could be made case insensitive with the i modifier.

    More important, if more than one <cpan> element is present in one line, .* will act greedily and gobble more than what you intend to gobble.

    For example

    <cpan>First::module</cpan> and <cpan>Second::Module</cpan>

    will be collapsed into

    [cpan://First::Module</cpan> and <cpan>Second::Module]

    which is certainly wrong.

    You can make * non greedy adding ?:

    <cpan>(.*)</cpan> becomes <cpan>(.*?)</cpan>

    Other than this, you may want to check Death to Dot Star! for a number of reasons why .* should be avoided when possible.

    -- TMTOWTDI