I need a little bit of help trying to parse something.. I've modified
makespec.r to add a couple of new options to help me generate some HTML
documentation for a project I'm working on. They're not very general
purpose options, but I'm quite happy with how easy it was to get
something quick-and-dirty going. If anyone's interested, I'd be happy
to mail you my changes. For example, to generate a two-column table,
with the first column in bold, I can use:
#table
#row "1st Column" "2nd Column"
#row "row 2 col 1" "row 2 col 2"
/table
For this change, I modified makespec.r like this:
parts: [newline | "===" section | "---" subsect |
"#indent" (emit marg-in) | "/indent" (emit marg-out) |
"#side" side | "/side" (emit [</TD></TR></TABLE>]) |
"#table" table | "/table" (emit [</TABLE>]) |
"#row" row |
"###" to end (emit [marg-out "-End-"]) | example | paragraph]
...
table: [(emit [<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0"
WIDTH="80%"> newline])]
quoted: [some space "^"" copy text to "^"" "^""]
row: [quoted (emit [<tr><td><b>text</b></td>])
quoted (emit [<td>text</td></tr> newline])]
Here's the problem.. I'd like to be able to embed HTML tags inside a
few of these tables, and some of those tags have embedded quotes, like
so:
#row "Protocols" "<a href="tcpprotocol.html#DB1">DB1</a> <a
href="tcpprotocol.html#DB2">DB2</a>"
Had I thought this through, I could have changed my quote character to
something else, but I'm sure REBOL will let me parse this if only I
could figure out how. Basically, I'd like to modify the 'quoted' rule
to ignore quotes inside of <> markers. How can I encode an algorithm
like:
quoted: [some space "^"" copy text to either "<" (in which case skip to
">" and keep going)
or "^"" "^""]
into valid REBOL code? I tried a few approaches but couldn't get
anything to work. Another alternative would be for me to escape the
embedded quote marks, but then I'd need to figure out how to transform
them back for the final text block.
Any help would be greatly appreciated. For extra credit, if someone can
figure out a way to modify the row: rule to process an arbitrary number
of columns (terminated by newline) instead of just two, that would make
this new rule a lot more general purpose and probably useful to more
people without modification.
-Jake