Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

XML-style readmore not being parsed

by premchai21 (Curate)
on Jan 21, 2003 at 22:09 UTC ( #228863=monkdiscuss: print w/ replies, xml ) Need Help??

Entering <readmore />, as opposed to <readmore>, into a post seems to bypass the readmore parser and do nothing. Should this really be the case? It would seem to me that omitting the empty-tag slash would cause the node contents to be non-well-formed XML.

Comment on XML-style readmore not being parsed
Re: XML-style readmore not being parsed (no kidding)
by tye (Cardinal) on Jan 21, 2003 at 22:42 UTC

    People don't generally type well-formed XML very accurately so we don't parse the text you enter as XML.

    You can say <readmore> and </readmore>. It doesn't make much sense to support <readmore /> since it isn't a self-contained tag but rather an opening tag that applies to the rest of your text. A closing tag is assumed at the end for the sake of sanity. If this bothers you, then put the closing tag in at the end yourself.

    You can't even insert spaces in either the opening or closing tag. We ignore letter case, that's it. You can't even just stuff it inside <code> tags as the processing of READMORE, CODE, [links], and HTML are all done in separate passes (in part because some content only has some of these applied and in part for historical reasons) and READMORE is processed before CODE (in part for efficiency and in part for hysterical raisins).

                    - tye

    Thanks to jeffa for pointing out my typo.

Re: XML-style readmore not being parsed
by theorbtwo (Prior) on Jan 22, 2003 at 02:19 UTC

    tye gave the technical reasons why that /doesn't/ work, and did a good job, but he rather skimmed over the logical reasons why it /shouldn't/ work.

    Logicaly, readmore isn't an empty tag that has an effect at a single place in your XHTML. Instead, it's a block-level (?) tag, which has an opening and a closing, and hides it's interior unless you're looking directly at the node (IE it's the root node of the page you're looking at). For convience, we allow you to ommit the close tag, in which case it's taken to be at the end of your node.

    The empty-tag form in XML (that is <tag />) is defined to be a shortcut for opening, and then immedatly closing again (<tag></tag>). Thus, it logicaly should hide nothing, that is, do nothing.

    (Of course, this doesn't explain why things /are/ they way they are, it mearly explains why they should be the way they are. tye's explanition is, as usual, correct, I just wanted to give another viewpoint, and explain why this isn't mearly a WONTFIX bug, but not really a bug at all.)


    Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

Readmore in source
by QwertyD (Pilgrim) on Jan 22, 2003 at 04:35 UTC

    On a semi-related note, speaking of well-formed SGML, is there a good reason why the <readmore> tag appears in the HTML that's sent to the browser? The browser can't do anything with it directly, it makes it even harder for the page to validate, and it prevents tools like HTML-Tidy from processing the source until the <readmore> is manually removed.

    While I understand that there are good reasons to be able to figure out where and if a page contains a <readmore>, why couldn't it be transformed to <!-- readmore --> before the HTML is sent to the browser?

    Then again, I'm sure there's probably a good reason and I just can't think of/find it.


    How do I love -d? Let me count the ways...

      I belive the reason is efficency. If you're looking at the node directly, the entire pass devoted to processing <readmore>s is skipped. It seems silly to run the pass just so we can change it into a comment, when it already isn't doing any harm. Yeah, it makes it a little harder to validate, but that's a rather minor concern. (It isn't actualy that much of an efficency issue, either, but I don't see the benifit in writing the code to do it.)


      Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

      1. Because the easiest "solution" was to just add "readmore" to the list of approved HTML tags.
      2. Because this node contains <!-- readmore --> (here:) but contains no <readmore> tag.
      3. Because eventually we should provide a better solution that offers links like
        • "read less" (redisplay this node but with READMORE bits hidden)
        • "read more" (default thread display)
        • "read all" (redisplay this thread with all READMORE bits shown for all replies)
        • "hide replies" or otherwise adjust the replies depth to display
        • etc.
        and (we hope) have "read less" only appear if there is a <readmore> hiding in the current node.
      4. Because our nodes are rarely "valid" so only crazy people try to have them validate and a tool called "HTML Tidy" shouldn't require you to tidy up the HTML before you give it to it. q-:
      We also should eventually have a [ ] readless option during Preview.

                      - tye

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: monkdiscuss [id://228863]
Approved by mojotoad
Front-paged by newrisedesigns
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (13)
As of 2014-07-31 16:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (249 votes), past polls