From 7ac83e25c90c4d05b9e9e39be678b32790e94f31 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Tue, 26 Oct 2010 05:20:02 -0400 Subject: [PATCH] Provide `process-begin/text' to make it convenient to define more `scribble/text'-like languages. Use it to define a convenient syntax for html modules. This is not used by the web content files since they define functions rather than spit out html when required, but makes it convenient to make an html markup language similar to scribble/text. --- collects/meta/web/html/main.rkt | 17 +++++++++++------ collects/scribble/text/lang/reader.rkt | 5 ++--- collects/scribble/text/syntax-utils.rkt | 4 ++-- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/collects/meta/web/html/main.rkt b/collects/meta/web/html/main.rkt index f778e81bc7..aab0a8c226 100644 --- a/collects/meta/web/html/main.rkt +++ b/collects/meta/web/html/main.rkt @@ -1,16 +1,16 @@ #lang racket/base -(provide (except-out (all-from-out racket/base) #%top) - (rename-out [top #%top]) - ;; to be used as a text language +(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 - (rename-out [begin/text 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")) (require "xml.rkt" "html.rkt" "resource.rkt" - scribble/text (for-syntax racket/base)) + scribble/text scribble/text/syntax-utils (for-syntax racket/base)) (define-syntax (top stx) (syntax-case stx () @@ -19,3 +19,8 @@ (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/text/lang/reader.rkt b/collects/scribble/text/lang/reader.rkt index d9660753ae..8c6ab72d47 100644 --- a/collects/scribble/text/lang/reader.rkt +++ b/collects/scribble/text/lang/reader.rkt @@ -7,6 +7,5 @@ scribble/text/textlang #:whole-body-readers? #t #:info (scribble-base-reader-info) -(require (prefix-in scribble: "../../reader.ss") - (only-in scribble/base/reader - scribble-base-reader-info)) +(require (prefix-in scribble: scribble/reader) + (only-in scribble/base/reader scribble-base-reader-info)) diff --git a/collects/scribble/text/syntax-utils.rkt b/collects/scribble/text/syntax-utils.rkt index 5ec450eb5c..fea2a06108 100644 --- a/collects/scribble/text/syntax-utils.rkt +++ b/collects/scribble/text/syntax-utils.rkt @@ -2,8 +2,8 @@ (require "output.ss" (for-syntax scheme/base syntax/kerncase)) -(provide module-begin/text begin/text include/text - begin/collect) +(provide module-begin/text begin/text include/text begin/collect + process-begin/text) (begin-for-syntax (define definition-ids ; ids that don't require forcing