Last active
December 18, 2015 02:38
-
-
Save gchiu/5712068 to your computer and use it in GitHub Desktop.
convert embedded html tables to asciid doc format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REBOL [ | |
author: "Ingo Hohmann" | |
date: 2013-06-04 | |
purpose: "Change html tables to asciidoc format" | |
Version: 0.5 | |
] | |
ht2at: html-table-2asciidoc: funct [ input ] [ | |
output: copy #{} | |
space: #{20} | |
emit: func [text ] [ | |
if space <> text [ | |
append output text | |
] | |
] | |
remit: func [text [block!]] [ | |
emit reform text | |
] | |
text-rule: [ | |
copy text to "<" (emit text) | |
] | |
tag-rule: [ | |
"<" [ | |
; opening tags | |
["table" | |
here: | |
thru "</table>" | |
there: | |
(change/part here trim/lines copy/part here there there) | |
:here | |
; TODO: Add table setup | |
( | |
emit {[options="header"]^/|====^/} | |
) | |
thru ">" | |
] | |
| | |
["tr" | |
;(emit newline) | |
thru ">" (emit "|") | |
] | |
| | |
["td" thru ">" ] | |
| | |
["th" thru ">" ] | |
| | |
["tt" thru ">" ] | |
| | |
; closing tags | |
["/table" | |
(emit "|====^/") | |
thru ">" | |
] | |
| | |
["/td" | |
thru ">" | |
here: | |
[ | |
["</" :here] | |
| | |
[(emit "|")] | |
] | |
] | |
| | |
["/th" | |
thru ">" | |
here: | |
[ | |
["</" :here] | |
| | |
[(emit "|")] | |
] | |
] | |
| | |
["/tr" | |
(emit newline) | |
thru ">" | |
] | |
| | |
; catch all | |
["/" thru ">" ] | |
| | |
[thru ">"] | |
] | |
] | |
parse input [ | |
some [ | |
tag-rule | text-rule | |
] | |
] | |
either empty? output [ | |
input | |
][ | |
output | |
] | |
] |
Graphics
unview
^^^^^^
[options="header"]
|====
|Rebol 2|Rebol 3|Description
|unview/only window|unview window|Hide only the specified window
|unview/all|unview 'all|Hide all windows
|unview|unview none|Hide the last window opened
|====
now has a leading space after the first |====
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample Output
unview
^^^^^^
[format="csv"]
|=======
Rebol 2,Rebol 3,Description
unview/only window,unview window,Hide only the specified window
unview/all,unview 'all,Hide all windows
unview,unview none,Hide the last window opened
|=======
Parent-Face
^^^^^^^^^^^
[format="csv"]
|=======
Rebol 2,Rebol 3,Description
face/parent-face,parent-face? face,Get the parent-face of a given face
|=======
set-face
^^^^^^^^
[format="csv"]
|=======
Rebol 2,Rebol 3,Description
set-face/no-show face,set-face face,Sets a face without showing it
set-face,set-face/show,Sets a face and shows it
|=======
view
^^^^
[format="csv"]
|=======
Rebol 2,Rebol 3,Description
view/new,view/no-wait,Creates a new window and returns immediately
|=======