@@ -26,10 +26,11 @@ (require (for-syntax racket/base racket/syntax)) (require racket/list racket/function pollen/decode pollen/tag + net/uri-codec txexpr "dust.rkt") (provide html-fn html-fndef) @@ -72,11 +73,15 @@ html-section html-subsection html-newthought html-smallcaps html-center + html-block html-blockcode + html-index + html-dialogue + html-say html-verse html-link html-url html-fn html-fndef @@ -86,38 +91,53 @@ (define html-section (default-tag-function 'h2)) (define html-subsection (default-tag-function 'h3)) (define html-newthought (default-tag-function 'span #:class "newthought")) (define html-smallcaps (default-tag-function 'span #:class "smallcaps")) (define html-center (default-tag-function 'div #:style "text-align: center")) +(define html-dialogue (default-tag-function 'dl #:class "dialogue")) + +(define (html-block . elements) + `(section [[class "content-block"]] (div [[class "content-block-main"]] ,@elements))) (define (html-root . elements) + (invalidate-series) (define first-pass - (decode-elements elements + (decode-elements (append elements (list (html-footnote-block))) #:txexpr-elements-proc decode-hardwrapped-paragraphs #:exclude-tags '(script style figure table pre))) (define second-pass (decode-elements first-pass #:block-txexpr-proc detect-newthoughts #:inline-txexpr-proc decode-link-urls #:string-proc (compose1 smart-quotes smart-dashes) #:exclude-tags '(script style pre code))) - `(body ,@second-pass ,(html-footnote-block))) + `(body ,@second-pass)) (define (html-blockcode attrs elems) (define file (or (assoc 'filename attrs) "")) (define codeblock `(pre [[class "code"]] (code ,@elems))) (cond [(string>? file "") `(@ (div [[class "listing-filename"]] 128196 " " ,file) ,codeblock)] [else codeblock])) +(define (html-index . elems) + `(a [[id ,(here-id (list "_idx-" (uri-encode (car elems))))] + [href ,(string-append "/keyword-index.html#" (uri-encode (string-downcase (car elems))))] + [data-index-entry ,(car elems)] + [class "index-link"]] + ,@(cdr elems))) + +(define (html-say . elems) + `(@ (dt ,(car elems) (span [[class "x"]] ": ")) (dd ,@(cdr elems)))) + (define (html-verse attrs elems) - (let* ([title (or (assoc 'title attrs) "")] + (let* ([title (maybe-attr 'title attrs "")] [italic? (assoc 'italic attrs)] [pre-attrs (cond [italic? '([class "verse"] [style "font-style: italic"])] [else '([class "verse"])])] - [pre-title (cond [(string>? title "") '(p [[class "verse-heading"]] ,title)] + [pre-title (cond [(string>? title "") `(p [[class "verse-heading"]] ,title)] [else ""])]) - `(div [[class "poem"]] (pre ,pre-attrs ,pre-title ,@elems)))) + `(div [[class "poem"]] ,pre-title (pre ,pre-attrs ,@elems)))) ;; There is no way in vanilla CSS to create a selector for “p tags that contain ;; a span of class ‘newthought’”. So we can handle it at the Pollen processing level. (define (detect-newthoughts block-xpr) (define (is-newthought? tx) ; Helper function @@ -190,6 +210,6 @@ `(li [[id ,(fndef-id fn-name)]] ,@definition-text ,@backrefs)))) (cond [(null? note-items) ""] [else `(section ((class "footnotes")) (hr) (ol ,@note-items))])) (define (html-note attrs elems) - (txexpr 'note attrs (decode-paragraphs elems #:force? #t))) + (txexpr 'note attrs (decode-hardwrapped-paragraphs elems)))