in reply to Re: Perl Monks hypocrisy
in thread Perl Monks hypocrisy

For what it's worth, I think tye's post sets out a plausible road map for dealing with this issue:

  1. The new functionality remains inactive if the text of a post contains anything that looks like tagged markup. (This could be a conservative test, such as /\<\w+/.)
  2. The auto-markup process should be paragraph oriented rather than line oriented, except that indented lines should get code treatment. (Similar to POD.)
  3. Rather than round-trip conversions, the function be applied in one direction, at the time the message is being edited. On the preview page, if the post doesn't seem to contain any tags, show an auto-markup version on the bottom of the page, and give the user an "Auto-Markup" button that applies the markup and shows the preview again.

Am I sweeping too many details under the carpet, or might this only require a handful of lines of new code?

# In site init code somewhere use HTML::FromText; my %text2html_options = map ($_=>1) qw(paras blockcode urls email); ... # In preview form command handler if ( $op = "auto-format" ) { $doctext = text2html( $doctext, %text2html_options ); } ... # At bottom of preview page if ( $doctext !~ /\<\w+/ ) { my $markup = text2html( $doctext, %text2html_options ); if ( $doctext ne $markup ) { print "<hr>If the automatic formatting below looks correct, you ca +n apply it with <input type="submit" name="op" value="auto-format" /> +. <p>$markup"; } } ...