> REBOL [Title: "Text to HTML Converter" Author: "Carl" File:
%text-html.r]
> 
> file: to-file ask "Filename? (w/o suffix) "

        Asking user for file name.

> html: make string! 10000
> emit: func [data] [append html reduce data]

> a+: <font face="arial,helvetica">
> a-: </font>

        HTML tags.

> space: charset " ^-"
> chars: complement charset " ^-^/"

        Charsets.

> indented: [some space thru newline]
> text-line: [copy text thru newline]

> section: [text-line (emit [<p>a+<h3>trim text</h3>a-<p>]) newline]
> subsect: [text-line (emit [<p>a+<i><h4>trim text</h4></i>a-<p>])
newline]
> example: [copy code some [indented | some newline indented]
>         (emit [<b><pre>code</pre></b><p>newline])]
> paragraph: [copy para some [chars thru newline] (emit [para<p>])]

> title: [text-line (emit
[<html><title>text</title><body>a+<h2>text</h2>a-<p>])]

Bug! Should have head tag surrounding title tags.

> parts: [newline | "===" section | "---" subsect | example |
paragraph]
> done: [(emit [</body></html>])]

> parse/all detab read join file ".txt" [title some parts done]

        Parenthesis help:
        parse/all (detab (read (join file ".txt"))) [title some parts done]

> write join file ".html" html

        Write the file.

> quit

        Stop!

Andrew Martin
[EMAIL PROTECTED]
http://members.xoom.com/AndrewMartin/
Online @ 33,600 Baud!
-><-


----------
> From: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> Subject: [REBOL] Parse Question:  Why Doesn't This Work? Re:(5)
> Date: Tuesday, 28 September 1999 9:42 PM
> 
> 
> 
> 
>   Petr,
> 
>   Thanks, actually dug that post up already and been trying to
> decypher it...  My closest approximations still aren't working.
> 
>   Perhaps someone will be kind enough to do a full step by 
> step breakdown of the stuff below?  Feel like I understand it
> pretty well, it's just not working when I go to implement my
> own version of the same.
> 
>   Would really appreciate it.
> 
>   Cheerfulness,
> 
>                                               ------EAT
> 
> [EMAIL PROTECTED] wrote:
> > Here's another example of something useful to do with parse.
> > I use this script to avoid writing my docs directly in HTML
> > (or in an HTML editor... of which I've tried dozens but never
> > found a good one).
> > 
> > Here's what it does:
> > 
> >    - the first line is the page title
> >    - indented lines are examples (monospaced preformatted)
> >    - lines starting with === are main sections
> >    - lines starting with --- are sub-sections
> >    - normal lines are just paragraphs (empty line for new)
> > 
> > There are a number of other features that I'll be adding,
> > but I thought I'd email it to you while it's still small and
> > cute. :)
> > 
> > I'll send you an example of the text in just a few minutes.
> > 
> > -Carl
> > 
> > (PS: Might be somewhat advanced for novices.)
> > 
> > REBOL [Title: "Text to HTML Converter" Author: "Carl" File:
%text-html.r]
> > 
> > file: to-file ask "Filename? (w/o suffix) "
> > 
> > html: make string! 10000
> > emit: func [data] [append html reduce data]
> > space: charset " ^-"
> > chars: complement charset " ^-^/"
> > a+: <font face="arial,helvetica">
> > a-: </font>
> > 
> > parts: [newline | "===" section | "---" subsect | example |
paragraph]
> > text-line: [copy text thru newline]
> > title: [text-line (emit
[<html><title>text</title><body>a+<h2>text</h2>a-<p>])]
> > 
> > section: [text-line (emit [<p>a+<h3>trim text</h3>a-<p>]) newline]
> > subsect: [text-line (emit [<p>a+<i><h4>trim text</h4></i>a-<p>])
newline]
> > paragraph: [copy para some [chars thru newline] (emit [para<p>])]
> > indented: [some space thru newline]
> > example: [copy code some [indented | some newline indented]
> >         (emit [<b><pre>code</pre></b><p>newline])]
> > done: [(emit [</body></html>])]
> > 
> > parse/all detab read join file ".txt" [title some parts done]
> > write join file ".html" html
> > quit

Reply via email to