From 4743ffdc187dbc098c102243b463135786588559 Mon Sep 17 00:00:00 2001 From: Keith Lazuka Date: Sun, 4 Oct 2009 07:17:54 -0400 Subject: [PATCH] help.html: with-nesting-block now maps to an HTML DIV with display: inline-block CSS style This change allowed me to remove the old hack that suppressed newlines in the stream if they occurred immediately after a DIV. --- basis/help/help.factor | 4 ++-- basis/help/markup/markup.factor | 6 ++++-- basis/html/streams/streams.factor | 34 +++++++++---------------------- 3 files changed, 16 insertions(+), 28 deletions(-) diff --git a/basis/help/help.factor b/basis/help/help.factor index 8f8ad35bf4..ddd6ce23fc 100644 --- a/basis/help/help.factor +++ b/basis/help/help.factor @@ -120,12 +120,12 @@ M: word set-article-parent swap "help-parent" set-word-prop ; title-style get [ [ ($title) ] [ ($navigation) ] bi ] with-nesting - ] with-style nl ; + ] with-style ; : print-topic ( topic -- ) >link last-element off - [ $title ] [ nl article-content print-content nl ] bi ; + [ $title ] [ ($blank-line) article-content print-content ] bi ; SYMBOL: help-hook diff --git a/basis/help/markup/markup.factor b/basis/help/markup/markup.factor index d0cfb675a7..845092fa03 100644 --- a/basis/help/markup/markup.factor +++ b/basis/help/markup/markup.factor @@ -26,6 +26,9 @@ SYMBOL: blank-line last-blank-line? not and [ nl ] when ; +: ($blank-line) ( -- ) + nl nl blank-line last-element set ; + : ($span) ( quot -- ) last-block? [ nl ] when span last-element set @@ -44,7 +47,6 @@ M: f print-element drop ; : with-default-style ( quot -- ) default-span-style get [ - last-element off default-block-style get swap with-nesting ] with-style ; inline @@ -220,7 +222,7 @@ PRIVATE> ] ($subsection) ; : $subsections ( children -- ) - [ $subsection* ] each nl nl blank-line last-element set ; + [ $subsection* ] each ($blank-line) ; : $subsection ( element -- ) first $subsection* ; diff --git a/basis/html/streams/streams.factor b/basis/html/streams/streams.factor index 1b3086f665..c6a2b08c00 100644 --- a/basis/html/streams/streams.factor +++ b/basis/html/streams/streams.factor @@ -10,22 +10,10 @@ GENERIC: url-of ( object -- url ) M: object url-of drop f ; -TUPLE: html-writer data last-div ; +TUPLE: html-writer data ; >last-div ; inline - -: a-div ( stream -- stream ) - t >>last-div ; inline - : new-html-writer ( class -- html-writer ) new V{ } clone >>data ; inline @@ -107,7 +95,7 @@ MACRO: make-css ( pairs -- str ) TUPLE: html-span-stream < html-sub-stream ; M: html-span-stream dispose - end-sub-stream not-a-div format-html-span ; + end-sub-stream format-html-span ; : border-css, ( border -- ) "border: 1px solid #" % hex-color, "; " % ; @@ -124,10 +112,8 @@ CONSTANT: pre-css "white-space: pre; font-family: monospace;" { border-color border-css, } { inset padding-css, } } make-css - ] [ - wrap-margin swap at - [ pre-css append ] unless - ] bi ; + ] [ wrap-margin swap at [ pre-css append ] unless ] bi + "display: inline-block;" append ; : div-tag ( xml style -- xml' ) div-css-style @@ -139,7 +125,7 @@ CONSTANT: pre-css "white-space: pre; font-family: monospace;" TUPLE: html-block-stream < html-sub-stream ; M: html-block-stream dispose ( quot style stream -- ) - end-sub-stream a-div format-html-div ; + end-sub-stream format-html-div ; : border-spacing-css, ( pair -- ) "padding: " % first2 max 2 /i # "px; " % ; @@ -157,16 +143,16 @@ PRIVATE> M: html-writer stream-flush drop ; M: html-writer stream-write1 - not-a-div [ 1string ] emit-html ; + [ 1string ] emit-html ; M: html-writer stream-write - not-a-div [ ] emit-html ; + [ ] emit-html ; M: html-writer stream-format format-html-span ; M: html-writer stream-nl - dup last-div? [ drop ] [ [ [XML
XML] ] emit-html ] if ; + [ [XML
XML] ] emit-html ; M: html-writer make-span-stream html-span-stream new-html-sub-stream ; @@ -178,12 +164,12 @@ M: html-writer make-cell-stream html-sub-stream new-html-sub-stream ; M: html-writer stream-write-table - a-div [ + [ table-style swap [ [ data>> [XML ><-> XML] ] with map [XML <-> XML] ] with map - [XML <->
XML] + [XML <->
XML] ] emit-html ; M: html-writer dispose drop ;