KBD

Keith Devens .com

Friday, November 21, 2008 Flag waving
"Fools! Don't they know that tears are a woman's most effective weapon?" – Catwoman (The Batman TV Series, episode 83)
← Windows Script HostI hate Norton Antivirus →

Daily link icon Tuesday, May 21, 2002

Fun stuff with my markup parser

I'm working out an extension syntax. From my comments in the to do list:

Add code blocks

  • Maybe I'll put in code blocks as my first extension! That's a good idea!
    • My extension syntax will probably be something like this: ?!extension_name:param1=value1&param2=value2
      • How do we escape "=" and "&" within the strings? URL encoding really isn't acceptible. It should really be just \= and \&, but that makes the result a little harder to parse. It's not a simple split anymore. Actually, I guess it could be a preg_split with a "negative lookbehind assertion". Nice! Problem solved. Regexes are good.
    • So the code extension will be something like: ?!code:language=php <- this way we can have language specific highlighters even Smiley
      • An extension function will be passed a reference to the markup, plus the current location, plus any parameters automatically parsed into an array.
      • An extension function must return the location at which to pick up parsing again.
        • How does this interact with some of the flags, such as the "output_directly" flag?
        • Ok, when the function returns, if "output_directly" is on, the master parser immediately outputs all lines from the start line passed to the extension to the end line number the extension returns. This implies that an extension must not modify lines above where it starts.
          • Are there any cases where we'd want to be able to modify output above where the extension starts?
      • The nice thing is that the extension function will have access to the entire document, so it can do whatever it wants. It chooses when to end, etc.
        • But how do we keep this regular so it'll be obvious when an extension ends? Must it be "?!extension_name" (maybe "?!/extension_name"?) again? That implies that each extension knows what its own name is, but that's not a big deal
        • The alternative is to have a consistent "end_extension" flag that every extension has to adhere to.
          • The first way, we have a chance at being able to do nested extensions.
          • But the second way is more regular
          • I have to think about it.
← Windows Script HostI hate Norton Antivirus →

Comments XML gif


Feel free to post a comment below. Please see my comment policy.

Formatting Rules (No HTML):

  • **bold**, *italic*, _underlined_, --strikeout--
  • "text"="url" creates a link, and URLs are auto-highlighted
  • Blockquote: Like e-mail, begin paragraph with > (greater-than sign)
  • Lists: begin paragraph with *,-, or + (unordered), or # (ordered)
  • Code block: ?!code:language=perl|php|sql|javascript|etc.{\n}...{\n}?!/code

:
(will be your IP address if blank)
: (optional)
(Will not be shown on site)

: (optional)
:

November 2008
SunMonTueWedThuFriSat
 1
2345678
9101112131415
16171819202122
23242526272829
30 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 5 posts

Recent comments XML

Calif. Supreme Court to take up gay marriage ban

I would argue the point is not​definitional.  While the word​marriage is su...

Justin: Nov 20, 4:37pm

Java join function

Meh, don't have null strings in​your string arrays imo, but you're​welcome ...

Keith: Nov 19, 7:51pm

Girls, please don't get breast implants

sorry but another thing i have to​make a comment on about you​men...the men...

happynow: Nov 17, 11:36pm

Books by Vincent Cheung

to all Cheung​fans:

read:

http://www.progin​osko.com/aquascum/cheung.h...

Zamir: Nov 16, 9:07am

Spider solitaire

To undo or not to undo that is the​question.
I'm an undoer. 
My dad​was n...

Can Turk: Nov 15, 2:50pm

Generated in about 0.178s.

(Used 8 db queries)

mobile phone