From 0bb6cd944af9b50e3fef49877aa6c25a57b7f92c Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Tue, 26 Oct 2010 15:36:29 -0400 Subject: [PATCH] Make the `scribble/html' layout mimic the one for `scribble/text'. Ie, the difference between using it as a language and as a module is now the same in both. Also, improve `scribble/html' (and `scribble/html/htmllang') by reproviding most of the corresponding text modules. Change `meta/web' accordingly, and improve code by making a new langugae (`#lang meta/web'). This language is similar to `scribble/html' except that it uses the plain scribble reader (not the `-inside' one), it doesn't use the customized module-begin feature (that uses `output-xml'), and it adds all the relevant bits of `meta/web/common'. (Also, "meta/web/common.rkt" is gone, since it's used only as a language now.) This commit has lots of details and binding games, so it's tricky, and potentially caused some problems. (Took me a while to track many breakages, so I won't be surprised if there are more.) original commit: 82221a51db9648d74caef31837b1f00b4e9d5773 --- collects/scribble/html/htmllang.rkt | 22 ++++++++++++++++++++++ collects/scribble/html/main.rkt | 28 ++++------------------------ collects/scribble/text.rkt | 5 ++--- collects/scribble/text/main.rkt | 7 +++++++ collects/scribble/text/textlang.rkt | 8 ++++---- 5 files changed, 39 insertions(+), 31 deletions(-) create mode 100644 collects/scribble/html/htmllang.rkt create mode 100644 collects/scribble/text/main.rkt diff --git a/collects/scribble/html/htmllang.rkt b/collects/scribble/html/htmllang.rkt new file mode 100644 index 00000000..4d47215f --- /dev/null +++ b/collects/scribble/html/htmllang.rkt @@ -0,0 +1,22 @@ +#lang racket/base + +(require "main.rkt" scribble/text/textlang scribble/text/syntax-utils + (for-syntax racket/base)) + +(provide (except-out (all-from-out scribble/text/textlang) + #%top #%module-begin) + (rename-out [top #%top] [module-begin #%module-begin]) + (all-from-out "main.rkt")) + +(define-syntax (top stx) + (syntax-case stx () + [(_ . x) + (let ([x* (syntax-e #'x)]) + (if (and (symbol? x*) (regexp-match? #rx":$" (symbol->string x*))) + #''x + #'(#%top . x)))])) + +(define-syntax-rule (module-begin expr ...) + (#%plain-module-begin + (port-count-lines! (current-output-port)) + (process-begin/text begin output-xml expr ...))) diff --git a/collects/scribble/html/main.rkt b/collects/scribble/html/main.rkt index 7b051527..0ab3b2aa 100644 --- a/collects/scribble/html/main.rkt +++ b/collects/scribble/html/main.rkt @@ -1,27 +1,7 @@ #lang racket/base -(provide (except-out (all-from-out racket/base) #%top #%module-begin) - (rename-out [top #%top] [module-begin #%module-begin]) - ;; to be used as a text language (output via `output-xml') - (all-from-out scribble/text) - ;; provide a `text' alias and an `include' alias - (rename-out [begin/text text] [include/text include]) - ;; main functionality - (all-from-out "xml.rkt" "html.rkt" "resource.rkt" - racket/list racket/string)) +(require "xml.rkt" "html.rkt" "resource.rkt" + ;; includes all of the scribble/text utilities + scribble/text) -(require "xml.rkt" "html.rkt" "resource.rkt" racket/list racket/string - scribble/text scribble/text/syntax-utils (for-syntax racket/base)) - -(define-syntax (top stx) - (syntax-case stx () - [(_ . x) - (let ([x* (syntax-e #'x)]) - (if (and (symbol? x*) (regexp-match? #rx":$" (symbol->string x*))) - #''x - #'(#%top . x)))])) - -(define-syntax-rule (module-begin expr ...) - (#%plain-module-begin - (port-count-lines! (current-output-port)) - (process-begin/text begin output-xml expr ...))) +(provide (all-from-out "xml.rkt" "html.rkt" "resource.rkt" scribble/text)) diff --git a/collects/scribble/text.rkt b/collects/scribble/text.rkt index 90c106d5..36f57156 100644 --- a/collects/scribble/text.rkt +++ b/collects/scribble/text.rkt @@ -1,5 +1,4 @@ #lang racket/base -(require racket/promise "text/output.ss" "text/syntax-utils.ss") -(provide (all-from-out racket/promise "text/output.ss") - begin/text include/text) +(require "text/main.rkt") +(provide (all-from-out "text/main.rkt")) diff --git a/collects/scribble/text/main.rkt b/collects/scribble/text/main.rkt new file mode 100644 index 00000000..5cc7ae6a --- /dev/null +++ b/collects/scribble/text/main.rkt @@ -0,0 +1,7 @@ +#lang racket/base + +(require "output.ss" "syntax-utils.ss" + racket/promise racket/list racket/string) + +(provide (all-from-out "output.ss" racket/promise racket/list racket/string) + begin/text include/text) diff --git a/collects/scribble/text/textlang.rkt b/collects/scribble/text/textlang.rkt index 0708781f..3df5a5a9 100644 --- a/collects/scribble/text/textlang.rkt +++ b/collects/scribble/text/textlang.rkt @@ -1,9 +1,9 @@ #lang racket/base -(require "syntax-utils.ss" "output.ss" racket/promise) +(require "syntax-utils.ss" "output.ss" + racket/promise racket/list racket/string) (provide (except-out (all-from-out racket/base) #%module-begin) - (all-from-out "output.ss" racket/promise) - begin/text + (all-from-out "output.ss" racket/promise racket/list racket/string) (rename-out [module-begin/text #%module-begin] - [include/text include])) + [begin/text text] [include/text include]))