]> gitweb.factorcode.org Git - factor.git/blob - unmaintained/easy-help/expand-markup/expand-markup.factor
7550158c7e942bd0133bf0da7f4c27b841218623
[factor.git] / unmaintained / easy-help / expand-markup / expand-markup.factor
1
2 USING: accessors arrays kernel lexer locals math namespaces parser
3        sequences splitting ;
4
5 IN: easy-help.expand-markup
6
7 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
8
9 : scan-one-array ( string -- array rest )
10   string-lines
11   lexer-factory get call
12   [
13   [
14     \ } parse-until >array
15     lexer get line-text>>
16     lexer get column>> tail
17   ]
18   with-lexer
19   ]
20   with-scope ;
21
22 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
23
24 : contains-markup? ( string -- ? ) "{ $" swap subseq? ;
25
26 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
27
28 :: expand-markup ( LINE -- lines )
29   
30   LINE contains-markup?
31     [
32     
33       [let | N [ "{ $" LINE start ] |
34
35         LINE N head
36
37         LINE N 2 + tail scan-one-array  dup " " head? [ 1 tail ] [ ] if
38
39         [ 2array ] dip
40
41         expand-markup
42
43         append ]
44         
45     ]
46     [ LINE 1array ]
47   if ;