Change how styles are handled in help markup
parent
31bead78f8
commit
9f94977cf4
|
@ -26,8 +26,8 @@ M: word article-content
|
||||||
] { } make ;
|
] { } make ;
|
||||||
|
|
||||||
: $title ( topic -- )
|
: $title ( topic -- )
|
||||||
title-style [
|
title-style get [
|
||||||
title-style [
|
title-style get [
|
||||||
dup [ 1array $link ] ($block) $doc-path
|
dup [ 1array $link ] ($block) $doc-path
|
||||||
] with-nesting
|
] with-nesting
|
||||||
] with-style terpri ;
|
] with-style terpri ;
|
||||||
|
@ -43,7 +43,7 @@ M: word article-content
|
||||||
|
|
||||||
: $subtopic ( element -- )
|
: $subtopic ( element -- )
|
||||||
[
|
[
|
||||||
subtopic-style [
|
subtopic-style get [
|
||||||
unclip f rot [ print-content ] curry write-outliner
|
unclip f rot [ print-content ] curry write-outliner
|
||||||
] with-style
|
] with-style
|
||||||
] ($block) ;
|
] ($block) ;
|
||||||
|
@ -55,11 +55,11 @@ M: word article-content
|
||||||
|
|
||||||
: $subsection ( element -- )
|
: $subsection ( element -- )
|
||||||
[
|
[
|
||||||
subsection-style [ first ($subsection) ] with-style
|
subsection-style get [ first ($subsection) ] with-style
|
||||||
] ($block) ;
|
] ($block) ;
|
||||||
|
|
||||||
: help-outliner ( seq quot -- )
|
: help-outliner ( seq quot -- )
|
||||||
subsection-style [
|
subsection-style get [
|
||||||
sort-articles [ ($subsection) ] [ terpri ] interleave
|
sort-articles [ ($subsection) ] [ terpri ] interleave
|
||||||
] with-style ;
|
] with-style ;
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ M: f print-element drop ;
|
||||||
[ print-element ] with-style ;
|
[ print-element ] with-style ;
|
||||||
|
|
||||||
: with-default-style ( quot -- )
|
: with-default-style ( quot -- )
|
||||||
default-style [
|
default-style get [
|
||||||
last-element off
|
last-element off
|
||||||
H{ } swap with-nesting
|
H{ } swap with-nesting
|
||||||
] with-style ; inline
|
] with-style ; inline
|
||||||
|
@ -66,13 +66,13 @@ M: f print-element drop ;
|
||||||
|
|
||||||
! Some spans
|
! Some spans
|
||||||
|
|
||||||
: $snippet [ snippet-style print-element* ] ($span) ;
|
: $snippet [ snippet-style get print-element* ] ($span) ;
|
||||||
|
|
||||||
: $emphasis [ emphasis-style print-element* ] ($span) ;
|
: $emphasis [ emphasis-style get print-element* ] ($span) ;
|
||||||
|
|
||||||
: $strong [ strong-style print-element* ] ($span) ;
|
: $strong [ strong-style get print-element* ] ($span) ;
|
||||||
|
|
||||||
: $url [ url-style print-element* ] ($span) ;
|
: $url [ url-style get print-element* ] ($span) ;
|
||||||
|
|
||||||
: $terpri terpri terpri drop ;
|
: $terpri terpri terpri drop ;
|
||||||
|
|
||||||
|
@ -81,13 +81,13 @@ M: f print-element drop ;
|
||||||
last-element get [ terpri ] when ($block) ; inline
|
last-element get [ terpri ] when ($block) ; inline
|
||||||
|
|
||||||
: $heading ( element -- )
|
: $heading ( element -- )
|
||||||
[ heading-style print-element* ] ($heading) ;
|
[ heading-style get print-element* ] ($heading) ;
|
||||||
|
|
||||||
: ($code) ( presentation quot -- )
|
: ($code) ( presentation quot -- )
|
||||||
[
|
[
|
||||||
code-style [
|
code-style get [
|
||||||
last-element off
|
last-element off
|
||||||
>r presented associate code-style hash-union r>
|
>r presented associate code-style get hash-union r>
|
||||||
with-nesting
|
with-nesting
|
||||||
] with-style
|
] with-style
|
||||||
] ($block) ; inline
|
] ($block) ; inline
|
||||||
|
@ -117,7 +117,7 @@ M: f print-element drop ;
|
||||||
|
|
||||||
: $example ( element -- )
|
: $example ( element -- )
|
||||||
1 swap cut* swap "\n" join dup <input> [
|
1 swap cut* swap "\n" join dup <input> [
|
||||||
input-style format terpri print-element
|
input-style get format terpri print-element
|
||||||
] ($code) ;
|
] ($code) ;
|
||||||
|
|
||||||
: $markup-example ( element -- )
|
: $markup-example ( element -- )
|
||||||
|
@ -126,7 +126,7 @@ M: f print-element drop ;
|
||||||
|
|
||||||
: $warning ( element -- )
|
: $warning ( element -- )
|
||||||
[
|
[
|
||||||
warning-style [
|
warning-style get [
|
||||||
last-element off
|
last-element off
|
||||||
"Warning" $heading print-element
|
"Warning" $heading print-element
|
||||||
] with-nesting
|
] with-nesting
|
||||||
|
@ -136,7 +136,7 @@ M: f print-element drop ;
|
||||||
: >link ( obj -- obj ) dup link? [ <link> ] unless ;
|
: >link ( obj -- obj ) dup link? [ <link> ] unless ;
|
||||||
|
|
||||||
: ($link) ( article -- )
|
: ($link) ( article -- )
|
||||||
link-style [
|
link-style get [
|
||||||
dup article-title swap >link write-object
|
dup article-title swap >link write-object
|
||||||
] with-style ;
|
] with-style ;
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ M: f print-element drop ;
|
||||||
first ($link) ;
|
first ($link) ;
|
||||||
|
|
||||||
: $vocab-link ( element -- )
|
: $vocab-link ( element -- )
|
||||||
first link-style [
|
first link-style get [
|
||||||
dup <vocab-link> write-object
|
dup <vocab-link> write-object
|
||||||
] with-style ;
|
] with-style ;
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ M: f print-element drop ;
|
||||||
drop
|
drop
|
||||||
] [
|
] [
|
||||||
[
|
[
|
||||||
doc-path-style [
|
doc-path-style get [
|
||||||
"Parent topics: " write $links
|
"Parent topics: " write $links
|
||||||
] with-style
|
] with-style
|
||||||
] ($block)
|
] ($block)
|
||||||
|
@ -174,16 +174,16 @@ M: f print-element drop ;
|
||||||
|
|
||||||
: $grid ( content style -- )
|
: $grid ( content style -- )
|
||||||
[
|
[
|
||||||
table-content-style [
|
table-content-style get [
|
||||||
[ last-element off print-element ] tabular-output
|
[ last-element off print-element ] tabular-output
|
||||||
] with-style
|
] with-style
|
||||||
] ($block) table last-element set ;
|
] ($block) table last-element set ;
|
||||||
|
|
||||||
: $list ( element -- )
|
: $list ( element -- )
|
||||||
[ "-" swap 2array ] map list-style $grid ;
|
[ "-" swap 2array ] map list-style get $grid ;
|
||||||
|
|
||||||
: $table ( element -- )
|
: $table ( element -- )
|
||||||
table-style $grid ;
|
table-style get $grid ;
|
||||||
|
|
||||||
: $values ( element -- )
|
: $values ( element -- )
|
||||||
"Inputs and outputs" $heading
|
"Inputs and outputs" $heading
|
||||||
|
@ -209,8 +209,8 @@ M: f print-element drop ;
|
||||||
|
|
||||||
: ($see) ( word -- )
|
: ($see) ( word -- )
|
||||||
[
|
[
|
||||||
code-style [
|
code-style get [
|
||||||
code-style [ see ] with-nesting
|
code-style get [ see ] with-nesting
|
||||||
] with-style
|
] with-style
|
||||||
] ($block) ;
|
] ($block) ;
|
||||||
|
|
||||||
|
|
|
@ -1,99 +1,102 @@
|
||||||
! Copyright (C) 2005, 2006 Slava Pestov.
|
! Copyright (C) 2005, 2006 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
IN: help
|
IN: help
|
||||||
USING: styles ;
|
USING: styles namespaces ;
|
||||||
|
|
||||||
: default-style
|
SYMBOL: default-style
|
||||||
H{
|
H{
|
||||||
{ font "sans-serif" }
|
{ font "sans-serif" }
|
||||||
{ font-size 12 }
|
{ font-size 12 }
|
||||||
{ font-style plain }
|
{ font-style plain }
|
||||||
{ wrap-margin 500 }
|
{ wrap-margin 500 }
|
||||||
} ;
|
} default-style set-global
|
||||||
|
|
||||||
: link-style
|
SYMBOL: link-style
|
||||||
H{
|
H{
|
||||||
{ foreground { 0 0 0.3 1 } }
|
{ foreground { 0 0 0.3 1 } }
|
||||||
{ font-style bold }
|
{ font-style bold }
|
||||||
} ;
|
} link-style set-global
|
||||||
|
|
||||||
: emphasis-style
|
SYMBOL: emphasis-style
|
||||||
H{ { font-style italic } } ;
|
H{ { font-style italic } } emphasis-style set-global
|
||||||
|
|
||||||
: strong-style
|
SYMBOL: strong-style
|
||||||
H{ { font-style bold } } ;
|
H{ { font-style bold } } strong-style set-global
|
||||||
|
|
||||||
: title-style
|
SYMBOL: title-style
|
||||||
H{
|
H{
|
||||||
{ font "sans-serif" }
|
{ font "sans-serif" }
|
||||||
{ font-size 16 }
|
{ font-size 16 }
|
||||||
{ font-style bold }
|
{ font-style bold }
|
||||||
{ wrap-margin 500 }
|
{ wrap-margin 500 }
|
||||||
{ page-color { 0.8 0.8 1 1 } }
|
{ page-color { 0.8 0.8 1 1 } }
|
||||||
{ border-width 5 }
|
{ border-width 5 }
|
||||||
} ;
|
} title-style set-global
|
||||||
|
|
||||||
: doc-path-style
|
SYMBOL: doc-path-style
|
||||||
H{ { font-size 10 } } ;
|
H{ { font-size 10 } } doc-path-style set-global
|
||||||
|
|
||||||
: heading-style
|
SYMBOL: heading-style
|
||||||
H{
|
H{
|
||||||
{ font "sans-serif" }
|
{ font "sans-serif" }
|
||||||
{ font-size 14 }
|
{ font-size 14 }
|
||||||
{ font-style bold }
|
{ font-style bold }
|
||||||
} ;
|
} heading-style set-global
|
||||||
|
|
||||||
: subsection-style
|
SYMBOL: subsection-style
|
||||||
H{
|
H{
|
||||||
{ font "sans-serif" }
|
{ font "sans-serif" }
|
||||||
{ font-size 14 }
|
{ font-size 14 }
|
||||||
{ font-style bold }
|
{ font-style bold }
|
||||||
} ;
|
} subsection-style set-global
|
||||||
|
|
||||||
: subtopic-style
|
SYMBOL: subtopic-style
|
||||||
H{ { font-style bold } } ;
|
H{ { font-style bold } } subtopic-style set-global
|
||||||
|
|
||||||
: snippet-style
|
SYMBOL: snippet-style
|
||||||
H{
|
H{
|
||||||
{ font "monospace" }
|
{ font "monospace" }
|
||||||
{ foreground { 0.3 0.3 0.3 1 } }
|
{ foreground { 0.3 0.3 0.3 1 } }
|
||||||
} ;
|
} snippet-style set-global
|
||||||
|
|
||||||
: code-style
|
SYMBOL: code-style
|
||||||
H{
|
H{
|
||||||
{ font "monospace" }
|
{ font "monospace" }
|
||||||
{ font-size 12 }
|
{ font-size 12 }
|
||||||
{ page-color { 0.8 0.8 0.8 0.5 } }
|
{ page-color { 0.8 0.8 0.8 0.5 } }
|
||||||
{ border-width 5 }
|
{ border-width 5 }
|
||||||
{ wrap-margin f }
|
{ wrap-margin f }
|
||||||
} ;
|
} code-style set-global
|
||||||
|
|
||||||
: input-style
|
SYMBOL: input-style
|
||||||
H{ { font-style bold } } ;
|
H{ { font-style bold } } input-style set-global
|
||||||
|
|
||||||
: url-style
|
SYMBOL: url-style
|
||||||
H{
|
H{
|
||||||
{ font "monospace" }
|
{ font "monospace" }
|
||||||
{ foreground { 0.0 0.0 1.0 1.0 } }
|
{ foreground { 0.0 0.0 1.0 1.0 } }
|
||||||
} ;
|
} url-style set-global
|
||||||
|
|
||||||
: warning-style
|
SYMBOL: warning-style
|
||||||
H{
|
H{
|
||||||
{ page-color { 0.95 0.95 0.95 1 } }
|
{ page-color { 0.95 0.95 0.95 1 } }
|
||||||
{ border-color { 1 0 0 1 } }
|
{ border-color { 1 0 0 1 } }
|
||||||
{ border-width 5 }
|
{ border-width 5 }
|
||||||
} ;
|
} warning-style set-global
|
||||||
|
|
||||||
: table-content-style
|
SYMBOL: table-content-style
|
||||||
H{
|
H{
|
||||||
{ wrap-margin 350 }
|
{ wrap-margin 350 }
|
||||||
} ;
|
} table-content-style set-global
|
||||||
|
|
||||||
: table-style
|
SYMBOL: table-style
|
||||||
H{
|
H{
|
||||||
{ table-gap { 5 5 } }
|
{ table-gap { 5 5 } }
|
||||||
{ table-border { 0.8 0.8 0.8 1.0 } }
|
{ table-border { 0.8 0.8 0.8 1.0 } }
|
||||||
} ;
|
} table-style set-global
|
||||||
|
|
||||||
: list-style
|
SYMBOL: list-style
|
||||||
H{ { table-gap { 10 2 } } } ;
|
H{ { table-gap { 10 2 } } } list-style set-global
|
||||||
|
|
||||||
|
SYMBOL: bullet
|
||||||
|
"-" bullet set-global
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
USING: help io kernel prettyprint prettyprint-internals words ;
|
IN: help
|
||||||
|
USING: io kernel prettyprint prettyprint-internals words ;
|
||||||
|
|
||||||
: $prettyprinting-note
|
: $prettyprinting-note
|
||||||
drop {
|
drop {
|
||||||
|
|
Loading…
Reference in New Issue