Bug in either clean-script.r or the parser.
[1/2] from: bhandley::zip::com::au at: 5-Aug-2000 2:48
This is a multi-part message in MIME format.
------=_NextPart_000_0029_01BFFE87.A67D1AC0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
I've been using clean-script heavily recently, and have now tripped over the
following problem.
clean-script mangles the attached script.
Specifically it creates an unmatched "(" for the following line. In other
tests it could be a new "[".
table-start: [text-line (emitter/start-table trim text) newline]
The thing is it handles earlier such lines correctly, which leads me to
think about the parser.
I've think I've narrowed it down to the script not "consuming" the first "["
for this line. Instead load/next gets and it will return a block value.
I tried removing some lines before this line and the error moved. Same for
when you add extra lines - BUT they have to be of the same type not just any
old line.
Any ideas?
Thanks.
Brett.
---
>> my-rebol-stuff
== http://www.zipworld.com.au/~bhandley/rebol
------=_NextPart_000_0029_01BFFE87.A67D1AC0
Content-Type: application/octet-stream;
name="text-to-html.r"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="text-to-html.r"
REBOL [=0A Title: "Text to HTML Converter"=0A File: %text-to-html.r=0A Date: 29-Feb-2000=0A Author:
"Brett Handley"=0A Purpose: {=0A A useful doc formatting language. Converts text to=0A HTML
with titles, sections, sub-sections, and code.=0A Is used to create all REBOL How-to
documents.=0A }=0A Usage: {=0A The first line of the text file is the title of the=0A document.
All lines that are flush left will be=0A treated as paragraphs. A blank line will
separate=0A paragraphs. Indented lines are examples. They are=0A indented and printed
in monospaced bold font.=0A Sections and sub-sections of a document are separated=0A with
a line that begins with === or --- and the text=0A that follows them is shown in a special
font.=0A }=0A Comment: {=0A %texthtml.r was substantially changed by Brett Handley to
allow different types=0A of emitters to be used and became this script. The original
%texthtml.r=0A was by Carl Sassenrath.=0A Also add some more language features:=0A Table
of contents (with links) for sections and subsections=0A Rudimentary Tables.=0A When
starting a table include the number of columns after the brace.=0A }=0A Category: [markup
text file 3]=0A]=0A=0A;=0A; A couple of stack like operations=0A;=0A=0Aspop: function
[a-stack] [a-val] [=0A if 0 < length? a-stack [=0A a-val: last a-stack=0A remove back
tail a-stack=0A a-val=0A ]=0A]=0A=0Aspush: func [a-stack val] [=0A append/only a-stack
val=0A]=0A=0A;=0A; This replicates the output from the original texthtml.r=0A;=0A=0A;=0A;
This is my site's emitter.=0A;=0A=0Arebinfo-emitter: make object! [=0A html: none=0A table-columns:
none=0A initialise: func[] [=0A html: make string! 10000=0A table-columns: make block!
[]=0A toc-sections: none=0A toc-subsections: none=0A ]=0A finalise: func[] []=0A to-anchor:
func[x][=0A rejoin parse x none=0A ]=0A as-anchor: func[x][=0A reduce [build-tag compose
['a name (to-anchor x)] x </a>]=0A ]=0A as-link: func[x][=0A reduce [build-tag compose
['a href (rejoin [{#} to-anchor x])] x </a>]=0A ]=0A emit: func [data /only] [=0A append
html either only [data] [reduce data]=0A append html newline=0A ]=0A font: func [data]
[=0A reduce [<font face="helvetica, arial"> data </font>]=0A ]=0A toc-sections: none=0A toc-subsections:
none=0A title: func[evalue] [=0A emit [<html><head>]=0A emit [<title> evalue </title>
]=0A emit [</head>]=0A emit [<body> font reduce [<h2> evalue </h2>] <p> ]=0A ]=0A keywords:
func [evalue] [=0A insert find/tail html "</title>" rejoin [newline build-tag reduce
['META 'HTTP-EQUIV "keywords" 'CONTENT evalue] newline]=0A ]=0A section: func[evalue][=0A=0A ;If
this is the first section - plug in the toc before emitting.=0A if not toc-sections
[=0A emit [<ul> ]=0A toc-sections: add 1 length? html ; Mark position for toc=0A emit
[</ul> ]=0A ]=0A=0A ; Add this section to the sections toc=0A toc-sections: index?
insert at html toc-sections reduce [<li> as-link evalue </li> ]=0A=0A ; Emit this section=0A emit
[<h3> as-anchor evalue </h3> ]=0A emit [<ul> ]=0A toc-subsections: add 1 length? html
; Mark position for toc=0A emit [</ul> ]=0A ]=0A subsect: func[evalue] [=0A ; Add
this section to the sections toc=0A toc-subsections: index? insert at html toc-subsections
reduce [<li> as-link evalue </li> newline]=0A=0A ; Emit this subsection=0A emit [<h4>
as-anchor evalue </h4> ]=0A ]=0A start-table: func[evalue][=0A evalue: trim/head/tail
evalue=0A spush table-columns reduce [to-integer evalue 1]=0A emit [<table border="2"><tr><td
width="162">]=0A ]=0A table-current-column: func[][second last table-columns]=0A table-column-count:
func[][first last table-columns]=0A table-cell: func[evalue][=0A emit [</td>]=0A either
equal? table-current-column table-column-count [=0A emit [</tr><tr>]=0A change back
tail last table-columns 1=0A ][=0A change back tail last table-columns add table-current-column
1=0A ]=0A emit [<td>]=0A ]=0A end-table: func[evalue][=0A emit [</td></tr></table>]=0A spop
table-columns=0A ]=0A link: function[evalue] [href link-text][=0A href: first parse
evalue none=0A link-text: trim/head/tail copy at evalue add 1 length? href=0A emit
[<p> reduce [build-tag compose ['a href (href)] link-text </a>] </p> ]=0A ]=0A escape-html:
func [=0A "Format a code example"=0A code=0A ] [=0A replace/all code "&" "&"=0A replace/all
code "<" "<"=0A replace/all code ">" ">"=0A insert code [<b> <pre>]=0A emit append
code reduce [</pre> </b> ]=0A ]=0A]=0A=0Atext-to-html: make object! [=0A emitter: rebinfo-emitter=0A space:
charset " ^-"=0A chars: complement charset " ^-^/"=0A=0A ;--- Text Format Language:=0A rules:
[title some parts done]=0A title: [text-line (emitter/title text)]=0A parts: [=0A newline
|=0A "--k" keywords |=0A "===" section |=0A "---" subsect |=0A "-->" hyperlink |=0A "--{"
table-start |=0A "--|" table-cell |=0A "--}" table-end |=0A "###" to end |=0A example
| paragraph=0A ]=0A keywords: [text-line (emitter/keywords trim/head/tail text) newline]=0A section:
[text-line (emitter/section trim text) newline]=0A subsect: [text-line (emitter/subsect
trim text) newline]=0A table-start: [text-line (emitter/start-table trim text) newline]=0A table-cell:
[text-line (emitter/table-cell trim text) newline]=0A table-end: [text-line (emitter/end-table
trim text) newline]=0A hyperlink: [text-line (emitter/link trim text) ]=0A example: [=0A copy
code some [indented | some newline indented]=0A (emitter/escape-html code)=0A ]=0A paragraph:
[=0A copy para some [chars thru newline] (emitter/emit [para <p>])=0A ]=0A done: [(emitter/emit
[</body> </html>])]=0A text-line: [copy text thru newline]=0A indented: [some space thru
newline]=0A convert: func [data] [=0A emitter/initialise=0A parse/all append detab
data newline rules=0A emitter/finalise=0A emitter/html=0A ]=0A]=0A
------=_NextPart_000_0029_01BFFE87.A67D1AC0--
[2/2] from: allenk:powerup:au at: 5-Aug-2000 14:13
Hi Brett,
I've had a few problems occasionally with this script too. I tried hard to
track down the exact condition that caused the bug, but couldn't. I've also
noted that if run a few times in the same session it can accumulate indents.
Send your bug report direct to the author..
Cheers,
Allen K