Andrew,


Is this the script you mean? colorize.r by Jeff.

Cheers,

Allen K

 (did you To: and CC: this to the list or did SELMA hiccup?)


REBOL [
    Title:    "Colorizer"
    Author:   "Jeff Kreis"
    Email:    [EMAIL PROTECTED]
    File:     %colorize.r
    Date:     29-Sep-1999
    Purpose:  "Generates colorized html REBOL scripts"
    Needs:    2.1.3
    Category: [Utility Script]
]

colors: reduce [
    issue!       #993399
    tag!         #996633
    path!        #339933
    set-word!    #993366
    get-word!    #330099
    word!        #000000
    lit-word!    #000000
    function!    #339933
    native!      #339933
    refinement!  #330099
    string!      #336666
    datatype!    #000000
]

emit: func [x /ok][append output either ok [x][html-escape x]]
b-p: func [o c start end][
    emit copy/part start find/tail start o
    col-aux copy/part find/tail start o back end
    emit/ok c return true
]

col-aux: func [start /end/item][
    all [any [none? start tail? start] exit]
    set [item end] load/next start
    if none? :item [all [found? start emit copy start] exit]

    word-rule:  bind word-rule  'item
    other-rule: bind other-rule 'item

    catch [
        foreach rule [
            [block? :item b-p "[" "]" start end]
            [paren? :item b-p "(" ")" start end]
            [any [set-word? :item get-word? :item] emit/ok do other-rule]
            [word? :item value? :item emit/ok do word-rule]
            [found? x: select colors (z: type? :item) emit/ok do
other-rule ]
            [emit copy/part start end]
         ][all [all rule throw]]
    ] col-aux end
]

html-escape: func [str][
    foreach [from to] ["&" "&AMP;" "<" "&LT;" ">" "&GT;"][
        replace/all str from to
    ]
]

colorize: func [file /src/header/post-head][
    foreach [name c] [
        word-rule  [either action? get item [function!][type? get item]]
        other-rule [type? :item]
    ][
        set name compose/deep [ rejoin [ form build-tag [
            FONT COLOR (to-paren append copy [select colors] c)]
            html-escape copy/part start end "</FONT>"
            ]
       ]
    ]

    output: reform [
        <HTML><HEAD><TITLE> file </TITLE></HEAD>
        <BODY BGCOLOR="#FFFFFF" TEXT="#000000"><PRE><FONT COLOR="#666699">
    ]
    src: detab read file
    set [header post-head] load/next/header src
    if not object? :header [print "NO REBOL HEADER" halt]
    append output reform [html-escape copy/part src post-head </FONT>]
    col-aux post-head
    append output [</PRE></BODY></HTML>]
]





----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Tuesday, January 11, 2000 1:22 PM
Subject: [REBOL] Displaying REBOL script with embedded HTML on REBOL site


> Hi!
>
> Regarding the REBOL.org site.
>
> Is it possible that the script, which converts a REBOL script to HTML, be
> published on this REBOL user list?
>
> If improvements were made to this script, such as converting "<" to "&lt"
> and similar modifications were made, could this new script then be
> installed/added to the REBOL.org site?
>
> Thanks!
>
> Andrew Martin
> Direct action, direct REBOL!
> ICQ: 26227169
> [EMAIL PROTECTED]
> http://members.xoom.com/AndrewMartin/
> -><-
>
>
>

Reply via email to