in reply to Perl Monks hypocrisy

Can't anyone who maintains this board figure out how to add an auto-line-break feature?

No, we're all too stupid.

Seriously. Round-tripping is hard. Do you convert everything into a canonical form in the database and render it into HTML for display and then back to the poster's preferred form for editing? How do you deal with quirks and mistakes? Is it important to guarantee that the post is preserved as originally typed? There's also backwards compatibility to deal with, some 270,000 nodes that are stored as HTML fragments already.

If you have an easy solution, I'm all ears. I've been doing this long enough that I don't believe in many easy solutions, though.

Replies are listed 'Best First'.
Re: auto-line-break
by simonm (Vicar) on Jul 17, 2003 at 00:03 UTC

    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"; } } ...