commit f378a5eac6d6fea47a419bb26cd97380dd6ed7c2
parent 870bfd3ae691616f6fe2315cd1babe1eaa30bf8b
Author: Matthew Flatt <mflatt@racket-lang.org>
Date: Wed, 10 Mar 2010 22:17:51 +0000
add scribble/jfp
svn: r18507
original commit: 826fbdf16f98e008b8b4be39e423442aeed9e090
Diffstat:
9 files changed, 179 insertions(+), 2 deletions(-)
diff --git a/collects/scribble/jfp.ss b/collects/scribble/jfp.ss
@@ -0,0 +1,66 @@
+#lang scheme/base
+(require setup/main-collects
+ scribble/core
+ (except-in scribble/base author)
+ scribble/decode
+ scribble/html-properties
+ scribble/latex-properties
+ (for-syntax scheme/base))
+
+(provide abstract include-abstract
+ author author/short
+ affiliation affiliation-mark affiliation-sep)
+
+(define jfp-extras
+ (let ([abs (lambda (s)
+ (path->main-collects-relative
+ (build-path (collection-path "scribble") "jfp" s)))])
+ (list
+ (make-css-addition (abs "jfp.css"))
+ (make-tex-addition (abs "jfp.tex")))))
+
+;; ----------------------------------------
+;; Abstracts:
+
+(define abstract-style (make-style "abstract" jfp-extras))
+
+(define (abstract . strs)
+ (make-nested-flow
+ abstract-style
+ (decode-flow strs)))
+
+(define (extract-abstract p)
+ (unless (part? p)
+ (error 'include-abstract "doc binding is not a part: ~e" p))
+ (unless (null? (part-parts p))
+ (error 'include-abstract "abstract part has sub-parts: ~e" (part-parts p)))
+ (when (part-title-content p)
+ (error 'include-abstract "abstract part has title content: ~e" (part-title-content p)))
+ (part-blocks p))
+
+(define-syntax-rule (include-abstract mp)
+ (begin
+ (require (only-in mp [doc abstract-doc]))
+ (make-nested-flow abstract-style (extract-abstract abstract-doc))))
+
+;; ----------------------------------------
+;; Author
+
+(define (author . long)
+ (apply (apply author/short long) long))
+
+(define ((author/short . short) . long)
+ (make-paragraph
+ (make-style 'author jfp-extras)
+ (list
+ (make-multiarg-element "JFPAuthor" (list (decode-content short)
+ (decode-content long))))))
+
+(define (affiliation . txt)
+ (make-element (make-style "Affiliation" jfp-extras) (decode-content txt)))
+
+(define (affiliation-mark . txt)
+ (make-element (make-style "MarkSuperscript" jfp-extras) (decode-content txt)))
+
+(define (affiliation-sep)
+ (hspace 2))
diff --git a/collects/scribble/jfp/jfp.tex b/collects/scribble/jfp/jfp.tex
@@ -0,0 +1,5 @@
+
+\newcommand{\Affiliation}[1]{\\ #1}
+\newcommand{\MarkSuperscript}[1]{$^{#1}$}
+
+\newcommand{\JFPAuthor}[2]{\author[#1]{#2}}
diff --git a/collects/scribble/jfp/lang.ss b/collects/scribble/jfp/lang.ss
@@ -0,0 +1,31 @@
+#lang scheme/base
+(require scribble/doclang
+ scribble/core
+ (except-in scribble/base author)
+ scribble/decode
+ scribble/jfp
+ "../private/defaults.ss"
+ (for-syntax scheme/base))
+(provide (except-out (all-from-out scribble/doclang) #%module-begin)
+ (all-from-out scribble/jfp)
+ (all-from-out scribble/base)
+ (rename-out [module-begin #%module-begin]))
+
+;; No options, currently, but keep in case we want to support some:
+(define-syntax (module-begin stx)
+ (syntax-case* stx () (lambda (a b) (eq? (syntax-e a) (syntax-e b)))
+ [(_ id ws . body)
+ ;; Skip intraline whitespace to find options:
+ (and (string? (syntax-e #'ws))
+ (regexp-match? #rx"^ *$" (syntax-e #'ws)))
+ #'(module-begin id . body)]
+ [(_ id . body)
+ #'(#%module-begin id (post-process) () . body)]))
+
+(define ((post-process) doc)
+ (add-defaults doc
+ (string->bytes/utf-8
+ (format "\\documentclass{jfp}\n\\usepackage{times}\n\\usepackage{qcourier}\n"))
+ (scribble-file "jfp/style.tex")
+ (list (scribble-file "jfp/jfp.cls"))
+ #f))
diff --git a/collects/scribble/jfp/lang/reader.ss b/collects/scribble/jfp/lang/reader.ss
@@ -0,0 +1,15 @@
+#lang s-exp syntax/module-reader
+
+scribble/jfp/lang
+
+#:read scribble:read-inside
+#:read-syntax scribble:read-syntax-inside
+#:whole-body-readers? #t
+#:wrapper1 (lambda (t) (cons 'doc (t)))
+#:info (lambda (key defval default)
+ (case key
+ [(color-lexer)
+ (dynamic-require 'syntax-color/scribble-lexer 'scribble-inside-lexer)]
+ [else (default key defval)]))
+
+(require (prefix-in scribble: "../../reader.ss"))
diff --git a/collects/scribble/jfp/style.tex b/collects/scribble/jfp/style.tex
@@ -0,0 +1,3 @@
+
+\renewcommand{\titleAndVersionAndAuthors}[3]{\title[#2]{#1}#3\maketitle}
+\renewcommand{\titleAndEmptyVersionAndAuthors}[3]{\titleAndVersionAndAuthors{#1}{#1}{#3}}
diff --git a/collects/scribblings/scribble/generic.scrbl b/collects/scribblings/scribble/generic.scrbl
@@ -8,3 +8,5 @@
@include-section["base.scrbl"]
@include-section["manual-stub.scrbl"]
@include-section["sigplan.scrbl"]
+@include-section["jfp.scrbl"]
+
diff --git a/collects/scribblings/scribble/jfp.scrbl b/collects/scribblings/scribble/jfp.scrbl
@@ -0,0 +1,55 @@
+#lang scribble/manual
+@(require (except-in "utils.ss" author)
+ (for-label scribble/jfp))
+
+@(define-syntax-rule (def base-author)
+ (begin
+ (require (for-label scribble/base))
+ (define base-author @scheme[author])))
+@(def base-author)
+
+@title{JFP Paper Format}
+
+@defmodulelang[scribble/jfp]{The @schememodname[scribble/jfp]
+language is like @schememodname[scribble/manual], but configured with
+Latex style defaults to use the @filepath{jfp.cls} class
+file that is included with Scribble.}
+
+Latex output with @schememodname[scribble/jfp] uses a main-document
+version supplied to @scheme[title] as the short-form document name (to
+be used in page headers).
+
+@defproc[(abstract [pre-content pre-content?] ...) block?]{
+
+Generates a @tech{nested flow} for a paper abstract.}
+
+@defform[(include-abstract module-path)]{
+
+Similar to @scheme[include-section], but incorporates the document in the
+specified module as an abstract. The document must have no title or
+sub-parts.}
+
+@defproc[(author [name pre-content?] ...)
+ block?]{
+
+A replacement for @base-author from @schememodname[scribble/base].}
+
+@defproc[((author/short [short-name pre-content?] ...) [long-name pre-content?] ...)
+ block?]{
+
+Like @scheme[author], but allows the short-form names (to be used in
+page headers) to be specified separately from the long-form name.}
+
+@deftogether[(
+@defproc[(affiliation [place pre-content?] ...) element?]
+@defproc[(affiliation-mark [mark pre-content?] ...) element?]
+@defproc[(affiliation-sep) element?]
+)]{
+
+Use @scheme[affiliation] within @scheme[author] or the long-name part
+of @scheme[author/short] to specify affiliations after all authors.
+If different authors have different affiliations, use
+@scheme[affiliation-mark] with a number after each author, and then
+use @scheme[affiliation-mark] before each different affiliation within
+a single @scheme[affiliation], using @scheme[(affiliation-sep)] to
+separate affiliations.}
diff --git a/collects/scribblings/scribble/sigplan.scrbl b/collects/scribblings/scribble/sigplan.scrbl
@@ -26,7 +26,7 @@ Generates a @tech{nested flow} for a paper abstract.}
@defform[(include-abstract module-path)]{
-Similar to @scheme[include-path], but incorporates the document in the
+Similar to @scheme[include-section], but incorporates the document in the
specified module as an abstract. The document must have no title or
sub-parts.}
diff --git a/collects/scribblings/scribble/struct.scrbl b/collects/scribblings/scribble/struct.scrbl
@@ -118,7 +118,7 @@ coerced to one.
@deftogether[(
-@defproc[(make-styled-paragraph [style any/c][content list?]) paragraph?]
+@defproc[(make-styled-paragraph [content list?][style any/c]) paragraph?]
@defproc[(styled-paragraph? [v any/c]) boolean?]
@defproc[(styled-paragraph-style [p paragraph?]) style?]
)]{