#lang syntax coloring; Scribble syntax coloring

svn: r15607

original commit: 1ba7cf0926a46122d7f759a2dccf086e2ba939a9
This commit is contained in:
Matthew Flatt 2009-07-28 18:06:14 +00:00
parent feaf24cd36
commit 5d62e4e005
9 changed files with 46 additions and 8 deletions

View File

@ -259,6 +259,7 @@
(->* () () #:rest (listof pre-content?) element?)) (->* () () #:rest (listof pre-content?) element?))
(provide/contract (provide/contract
[linebreak (-> element?)]
[hspace (-> exact-nonnegative-integer? element?)] [hspace (-> exact-nonnegative-integer? element?)]
[elem (->* () [elem (->* ()
(#:style element-style?) (#:style element-style?)
@ -291,6 +292,9 @@
h)) h))
(make-element 'hspace (list (make-string n #\space))))) (make-element 'hspace (list (make-string n #\space)))))
(define (linebreak)
(make-element 'newline '("\n")))
(define (elem #:style [style plain] . str) (define (elem #:style [style plain] . str)
(make-element style (decode-content str))) (make-element style (decode-content str)))

View File

@ -6,5 +6,10 @@ scribble/base/lang
#:read-syntax scribble:read-syntax-inside #:read-syntax scribble:read-syntax-inside
#:whole-body-readers? #t #:whole-body-readers? #t
#:wrapper1 (lambda (t) (list* 'doc 'values '() (t))) #:wrapper1 (lambda (t) (list* 'doc 'values '() (t)))
#:info (lambda (key default)
(case key
[(color-lexer)
(dynamic-require 'syntax-color/scribble-lexer 'scribble-inside-lexer)]
[else (default key)]))
(require (prefix-in scribble: "../../reader.ss")) (require (prefix-in scribble: "../../reader.ss"))

View File

@ -1,3 +1,11 @@
#lang scheme/base #lang scheme/base
(require (prefix-in doc: scribble/doc/reader)) (require (prefix-in doc: scribble/doc/reader))
(provide (rename-out [doc:read read] [doc:read-syntax read-syntax])) (provide (rename-out [doc:read read] [doc:read-syntax read-syntax])
get-info)
(define (get-info . args)
(lambda (key)
(case key
[(color-lexer)
(dynamic-require 'syntax-color/scribble-lexer 'scribble-inside-lexer)]
[else #f])))

View File

@ -6,5 +6,10 @@ scribble/manual/lang
#:read-syntax scribble:read-syntax-inside #:read-syntax scribble:read-syntax-inside
#:whole-body-readers? #t #:whole-body-readers? #t
#:wrapper1 (lambda (t) (cons 'doc (t))) #:wrapper1 (lambda (t) (cons 'doc (t)))
#:info (lambda (key default)
(case key
[(color-lexer)
(dynamic-require 'syntax-color/scribble-lexer 'scribble-inside-lexer)]
[else (default key)]))
(require (prefix-in scribble: "../../reader.ss")) (require (prefix-in scribble: "../../reader.ss"))

View File

@ -47,6 +47,7 @@
(struct-out var-id) (struct-out var-id)
(struct-out shaped-parens) (struct-out shaped-parens)
(struct-out just-context) (struct-out just-context)
(struct-out alternate-display)
(struct-out literal-syntax) (struct-out literal-syntax)
(for-syntax make-variable-id (for-syntax make-variable-id
variable-id? variable-id?
@ -178,11 +179,12 @@
(memq (syntax-e c) (current-variable-list)))] (memq (syntax-e c) (current-variable-list)))]
[(s it? sub?) [(s it? sub?)
(let ([sc (syntax-e c)]) (let ([sc (syntax-e c)])
(let ([s (format "~s" (if (literal-syntax? sc) (let ([s (or (syntax-property c 'display-string)
(literal-syntax-stx sc) (format "~s" (if (literal-syntax? sc)
(if (var-id? sc) (literal-syntax-stx sc)
(var-id-sym sc) (if (var-id? sc)
sc)))]) (var-id-sym sc)
sc))))])
(if (and (symbol? sc) (if (and (symbol? sc)
((string-length s) . > . 1) ((string-length s) . > . 1)
(char=? (string-ref s 0) #\_) (char=? (string-ref s 0) #\_)
@ -763,6 +765,7 @@
(define-struct var-id (sym)) (define-struct var-id (sym))
(define-struct shaped-parens (val shape)) (define-struct shaped-parens (val shape))
(define-struct just-context (val ctx)) (define-struct just-context (val ctx))
(define-struct alternate-display (id string))
(define-struct literal-syntax (stx)) (define-struct literal-syntax (stx))
(define-struct graph-reference (bx)) (define-struct graph-reference (bx))
@ -792,6 +795,11 @@
s s
s s
(just-context-ctx v)))] (just-context-ctx v)))]
[(alternate-display? v)
(let ([s (do-syntax-ize (alternate-display-id v) col line ht #f)])
(syntax-property s
'display-string
(alternate-display-string v)))]
[(hash-ref (unbox ht) v #f) [(hash-ref (unbox ht) v #f)
=> (lambda (m) => (lambda (m)
(unless (unbox m) (unless (unbox m)

View File

@ -6,5 +6,10 @@ scribble/sigplan/lang
#:read-syntax scribble:read-syntax-inside #:read-syntax scribble:read-syntax-inside
#:whole-body-readers? #t #:whole-body-readers? #t
#:wrapper1 (lambda (t) (cons 'doc (t))) #:wrapper1 (lambda (t) (cons 'doc (t)))
#:info (lambda (key default)
(case key
[(color-lexer)
(dynamic-require 'syntax-color/scribble-lexer 'scribble-inside-lexer)]
[else (default key)]))
(require (prefix-in scribble: "../../reader.ss")) (require (prefix-in scribble: "../../reader.ss"))

View File

@ -272,6 +272,9 @@ gets progressively larger.}
@defproc[(emph [pre-content pre-content?] ...) element?]{ @defproc[(emph [pre-content pre-content?] ...) element?]{
The same as @scheme[italic].} The same as @scheme[italic].}
@defproc[(linebreak) element?]{
Produces an element that forces a line break.}
@defproc[(hspace [n exact-nonnegative-integer?]) element?]{ @defproc[(hspace [n exact-nonnegative-integer?]) element?]{
Produces an element containing @scheme[n] spaces and style Produces an element containing @scheme[n] spaces and style

View File

@ -60,7 +60,7 @@ in the case of Latex).
To add a mapping from your own style name to a CSS configuration, add To add a mapping from your own style name to a CSS configuration, add
a @scheme[css-addition] structure instance to a style's @tech{style property} a @scheme[css-addition] structure instance to a style's @tech{style property}
list. To map a style name to a Latex macro or environment, add a list. To map a style name to a Latex macro or environment, add a
scheme[tex-addition] structure instance. A @scheme[css-addition] or @scheme[tex-addition] structure instance. A @scheme[css-addition] or
@scheme[tex-addition] is normally associated with the style whose name @scheme[tex-addition] is normally associated with the style whose name
is implemented by the adition, but it can also be added to the style is implemented by the adition, but it can also be added to the style
for an enclosing part. for an enclosing part.

View File

@ -167,7 +167,7 @@ needed.
@{blah @|foo|: blah} @{blah @|foo|: blah}
}===| }===|
Actually, the command part can be any Scheme expression (that does Actually, the command part can be any Scheme expression (that does not
start with @litchar["["], @litchar["{"], or @litchar["|"]), which is start with @litchar["["], @litchar["{"], or @litchar["|"]), which is
particularly useful with such escapes since they can be used with any particularly useful with such escapes since they can be used with any
expression. expression.