For what it's worth, I think tye's post sets out a plausible road map for dealing with this issue:
- 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+/.)
- The auto-markup process should be paragraph oriented rather than line oriented, except that indented lines should get code treatment. (Similar to POD.)
- 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";
}
}
...
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.