Near as I can tell, this rule matches the principle shown in Carl's
stuff below:

headrule: [ some [newline |
        "===" [[copy header to newline]
        (       append header " (FIRST LEVEL)"
                append full-contents header)]           |
        "---" [[copy header to newline]
        (       append header " (SECOND LEVEL)"
                append full-contents header)]]
]

  Neat thing about this is it doesn't even return true, let alone give
me a listing of either FIRST, -o-r- SECOND level text in full-contents.

  Should have taken myself to bed a while ago, just can't seem to let
go of this and drop it.  Keep getting out of bed thinking I have it, but
no...

  Cheerfulness,

                                                ------EAT

[EMAIL PROTECTED] wrote:
> 
> [EMAIL PROTECTED] wrote:
> 
> > [EMAIL PROTECTED] wrote:
> >
> > > Okay, granted.  Here's the same rule with a different word...
> > >
> > > headrule: [some
> > >         [thru "=== " copy header to newline
> > >         (       append header " (FIRST LEVEL)"
> > >                 append full-contents header)            |
> > >         thru "--- " copy header to newline
> > >         (       append header " (SECOND LEVEL)"
> > >                 append full-contents header)    ]
> > > ]
> > >
> > > Now, I still only see FIRST LEVEL stored in full-contents while
> > > it's a fact lines with "--- " exist in the file being used...
> > >
> >
> > Aha, so I am sorry as I am not too skilled in grammar creation. The problem
> > seems to be with "find this value OR that value", as string will be parsed
> > thru first occurance of "===", and if "---" occured first, it will not be
> > reflected. That would require some "parralel" searching for parser or what,
> > so I am sorry I can't help. Anybody?
> 
> OK, commenting myself :-)
> 
> ->> str: {some text here === some other text here --- and the rest of the
> string}
> ->> ble: copy ""
> ->>  parse str [thru "---" copy rest to end (insert ble rest) | thru "===" copy
> rest to end (insert ble rest)]
> == true
> ->> ble
> == " and the rest of the string"
> 
> ; So, as you can see, "===" was not found, now let's try to redefine above
> parse expression using subrules
> 
> ->> parse str [[thru "---" copy rest to end (insert ble rest)] | [thru "==="
> copy rest to end (insert ble rest)]]
> == true
> ->> ble
> == " and the rest of the string"
> 
> ; hmm, doesn't work for me too ...
> 
> ->> parse str [thru ["---" "==="] copy rest to end (insert ble rest)]
> ** Script Error: Invalid argument: --- ===.
> ** Where: parse str [thru ["---" "==="] copy rest to end (insert ble rest)]
> 
> ; Ouch, don't know what to do about it ...., sorry ...
> ; doc's are stating: [some ["a" "b"]] - It will match any combination of a's
> and b's ... can't be used with 'thru probably ...
> 
> PS: pressed for the time now, but attaching one of Carl's emails a few months
> back sent to beta mailing list .... It seems it's what you are looking for ...
> 
> -pekr-
> 
> ---------------------------------
> 
> 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