         [ prefix ] bi*
     ] [ drop ] if ;
 
+: parse-help-examples ( -- seq )
+    \ } parse-until [ \ $example make-example ] { } map-as ;
+
 PRIVATE>
 
-SYNTAX: $examples{
-    \ } [
-        [ \ $example make-example ] { } map-as \ $examples prefix
-    ] parse-literal ;
+SYNTAX: $examples{ parse-help-examples \ $examples prefix suffix! ;
 
 SYNTAX: $example:
     scan-object \ $example make-example suffix! ;

    [ [ suffix! ] curry dip ] bi* ;

: push-help-space ( accum sbuf -- accum sbuf )
    2dup [ empty? ] both? [ CHAR: \s suffix! ] unless ;

:: parse-help-text ( end -- seq )
    V{ } clone SBUF" " clone [
        lexer get line>> end parse-help-token [
            lexer get line>> swap - 1 > [
                \ $nl push-help-text
            ] when

! Copyright (C) 2020 John Benediktsson
! See http://factorcode.org/license.txt for BSD license

USING: accessors arrays ascii combinators
combinators.short-circuit help help.markup help.topics kernel
lexer math namespaces parser sequences splitting strings vectors
vocabs.parser words ;

IN: easy-help

:: parse-help-token ( -- str/obj/f )
    ?scan-token dup search {
        { [ dup \ } eq? ] [ 2drop f ] }
        { [ dup parsing-word? ] [
            nip V{ } clone swap execute-parsing first
            dup wrapper? [ wrapped>> \ $link swap 2array ] when ] }
        [ drop ]
    } cond ;

