This plugin definitely isn't production ready; it can't handle nested tags. Still, the simple functionality it provides met my modest needs. Feel free to improve the code
--
WillNorris - 12 Oct 2003
1. I wonder if it is possible to add the ending tag automatically when a newline is encountered, so that
<subtitle>My necessary subtitle
would be renamed: <span class="subtitle">My necessary subtitle</span>
- this would prevent multiline tags from working (not that they work at the moment) -- WillNorris - 14 Oct 2003
- would a preferences item listing a set of tags to autoclose at eol be sufficient? -- WillNorris - 20 Oct 2003
2. I would suggest to use "class" instead of "id" as id should be used only once per page.
- the plugin already outputs
class unless you start the xml-like tag with # (e.g., <#id>id text</id>), or did i misunderstand? -- WillNorris - 14 Oct 2003
--
ArthurClemens - 12 Oct 2003
Version 1.001 handles nested tags now, but i may have significantly impacted the performance?
Also, I'm open to another name besides
PseudoXmlPlugin (it started as SimpleXmlPlugin; SimplePseudoXmlPlugin also came to mind)
--
WillNorris - 14 Oct 2003
On nested tag, what about the following algorithm (I didn't look at your code yet):
- when encountering
<[a-zA-Z_0-9]+>, look for tag in a table of allowed tags (HTML spec + wiki pseudo tags + local additions)
- if not found, replace by
<span class="\1">
- when encountering
<[/[a-zA-Z_0-9]+>, look for tag in same table
- if not found, replace by
</span>
Did I miss something? this way you can handle nested tags without performance overhead.
You may want to allow class and ID, as in:
<date#34>11 Oct 2003</date> would be renamed:
<span class="date" id='date#34'>11 Oct 2003</span>
(not
id=34 as it can conflict).
But I do not know if IDs are useful. they are potentially troublesome in case of conflicts.
And users could just as well use
<date_34>11 Oct 2003</date> to get this functionality without any need to code a special case.
--
ColasNahaboo - 14 Oct 2003
colas, for your example, did you mean to say
<date_34>11 Oct 2003</date_34>? as written, those tags wouldn't be expanded. alternatively, it could be written
<date#date_34>11 Oct 2003</date>. perhaps more verbose, but at the same time more flexible. the class and id combo is a good idea, but i'm not sure which format expansion is "right".
--
WillNorris - 20 Oct 2003
Well, since I propose to replace
any XXX in
</XXX> to
</span>, anything will work, even...
converting
</> to
</span>, allowing for the traditional sgml shorthand
<date_34>11 Oct 2003</>
--
ColasNahaboo - 21 Oct 2003
I was going to suggest exactly the same thing until I read the above. I also thought of
<> first as it doesn't require messing around with the shift key :). I wasn't aware
</> was a sgml tag so maybe it is more logical but I'd still prefer
<> for speed.
--
SamHasler - 20 Jan 2004
REX: XML Shallow Parsing with Regular Expressions
--
WillNorris - 21 Mar 2004
checked into
CVS
--
WillNorris - 14 Feb 2005