From 15202a9cf21d8f09d821364f0fe1cc934d94077d Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Wed, 24 Dec 2008 03:13:28 -0600 Subject: [PATCH] Add 'easy-help.expand-markup' --- .../expand-markup/expand-markup.factor | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 extra/easy-help/expand-markup/expand-markup.factor diff --git a/extra/easy-help/expand-markup/expand-markup.factor b/extra/easy-help/expand-markup/expand-markup.factor new file mode 100644 index 0000000000..7550158c7e --- /dev/null +++ b/extra/easy-help/expand-markup/expand-markup.factor @@ -0,0 +1,47 @@ + +USING: accessors arrays kernel lexer locals math namespaces parser + sequences splitting ; + +IN: easy-help.expand-markup + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: scan-one-array ( string -- array rest ) + string-lines + lexer-factory get call + [ + [ + \ } parse-until >array + lexer get line-text>> + lexer get column>> tail + ] + with-lexer + ] + with-scope ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: contains-markup? ( string -- ? ) "{ $" swap subseq? ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +:: expand-markup ( LINE -- lines ) + + LINE contains-markup? + [ + + [let | N [ "{ $" LINE start ] | + + LINE N head + + LINE N 2 + tail scan-one-array dup " " head? [ 1 tail ] [ ] if + + [ 2array ] dip + + expand-markup + + append ] + + ] + [ LINE 1array ] + if ; -- 2.34.1