diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..50b6bdd9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +*~ +\#* +.\#* +.DS_Store +compiled/ +/doc/ \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..c13790d1 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,56 @@ +language: c + +# Based from: https://github.com/greghendershott/travis-racket + +# Optional: Remove to use Travis CI's older infrastructure. +sudo: false + +env: + global: + # Supply a global RACKET_DIR environment variable. This is where + # Racket will be installed. A good idea is to use ~/racket because + # that doesn't require sudo to install and is therefore compatible + # with Travis CI's newer container infrastructure. + - RACKET_DIR=~/racket + matrix: + # Supply at least one RACKET_VERSION environment variable. This is + # used by the install-racket.sh script (run at before_install, + # below) to select the version of Racket to download and install. + # + # Supply more than one RACKET_VERSION (as in the example below) to + # create a Travis-CI build matrix to test against multiple Racket + # versions. + #- RACKET_VERSION=6.0 + #- RACKET_VERSION=6.1 + #- RACKET_VERSION=6.1.1 + #- RACKET_VERSION=6.2 + - RACKET_VERSION=6.3 + - RACKET_VERSION=6.4 + - RACKET_VERSION=6.5 + - RACKET_VERSION=6.6 + - RACKET_VERSION=HEAD + +matrix: + allow_failures: + fast_finish: true + +before_install: +- git clone https://github.com/greghendershott/travis-racket.git +- cat travis-racket/install-racket.sh | bash # pipe to bash not sh! +- export PATH="${RACKET_DIR}/bin:${PATH}" #install-racket.sh can't set for us + +install: + - raco pkg install --deps search-auto + +before_script: + +# Here supply steps such as raco make, raco test, etc. You can run +# `raco pkg install --deps search-auto` to install any required +# packages without it getting stuck on a confirmation prompt. +script: + - raco test -x -p scribble-enhanced + - raco setup --check-pkg-deps --no-zo --no-launcher --no-install --no-post-install --no-docs --pkgs scribble-enhanced + +after_success: + - raco pkg install --deps search-auto cover cover-coveralls + - raco cover -b -f coveralls -d $TRAVIS_BUILD_DIR/coverage . diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 00000000..eeb2fbce --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,34 @@ +scribble-enhanced + +Parts of this software were initially written as part of a project at +Cortus, S.A.S. which can be reached at: + Cortus S.A.S., 97 Rue de Freyr, 34000 Montpellier, France. + +This software is licensed under the GNU Lesser General Public License (LGPL). + +This license has been chosen in order to make it possible to integrate +the type-expander library with Typed/Racket +(https://github.com/racket/typed-racket) and/or Racket +(https://github.com/racket/racket), which are both under the LGPL license. + +The original repository from which this package has been extracted +(https://github.com/jsmaniac/phc, see the +fork-from-github-jsmaniac-phc tag) was under a double license (LGPL +and BSD). This choice was made to allow integrating code with Racket +(LGPL) and Typed/Racket (LGPL) as well as with the Nanopass Compiler +Framework (BSD, https://github.com/akeep/nanopass-framework). The BSD +license has been dropped for this package (scribble-enhanced) because +it now contains modified code from the scribble library +(https://github.com/racket/scribble/), which is licensed under the +LGPL license. + +---- + +This package is distributed under the GNU Lesser General Public +License (LGPL). This means that you can link scribble-enhanced into proprietary +applications, provided you follow the rules stated in the LGPL. You +can also modify this package; if you distribute a modified version, +you must distribute it under the terms of the LGPL, which in +particular means that you must release the source code for the +modified software. See http://www.gnu.org/copyleft/lesser.html +for more information. diff --git a/README.md b/README.md new file mode 100644 index 00000000..bc039ffa --- /dev/null +++ b/README.md @@ -0,0 +1,47 @@ +[![Build Status,](https://img.shields.io/travis/jsmaniac/scribble-enhanced/master.svg)](https://travis-ci.org/jsmaniac/scribble-enhanced) +[![Coverage Status,](https://img.shields.io/coveralls/jsmaniac/scribble-enhanced/master.svg)](https://coveralls.io/github/jsmaniac/scribble-enhanced) +[![Build Stats,](https://img.shields.io/badge/build-stats-blue.svg)](http://jsmaniac.github.io/travis-stats/#jsmaniac/scribble-enhanced) +[![Online Documentation.](https://img.shields.io/badge/docs-online-blue.svg)](http://docs.racket-lang.org/scribble-enhanced/) + +scribble-enhanced +================= + +This `racket` package provides enhancements for the scribble library. + +Installation +------------ + +Install with: + +``` +raco pkg install --deps search-auto scribble-enhanced +``` + +This library is unstable +------------------------ + +For now, this package's API should be considered unstable. +Append `#COMMIT_NUMBER` at the end of `…scribble-enhanced.git` +in the command-line above to specify a version to install +(it will not be automatically updated by `raco pkg update` that way). + +Files +----- + +* `doc.rkt` + Enhancements and utilities for documentation and literate programming files + using scribble and scribble/lp2. + +* `math.rkt` + + Allows typesetting mathematical formulas in documentation and literate + programming files using scribble and scribble/lp2. + +* `scribblings/scribble-enhanced-template.lp2.rkt` + + Example document using the features in `doc.rkt` and `math.rkt`. + +* `scribblings/scribble-enhanced-example.lp2.rkt` + + Other simpler example document using the features in `doc.rkt` and + `math.rkt`. diff --git a/doc.rkt b/doc.rkt new file mode 100644 index 00000000..85cd9ffc --- /dev/null +++ b/doc.rkt @@ -0,0 +1,170 @@ +#lang racket + +;; Math +(require slideshow/pict) +(provide (all-from-out slideshow/pict)) +(require "math.rkt") +(provide (all-from-out "math.rkt")) +; @setup-math is returned in @doc-lib-setup. + + +(require scriblib/render-cond) + +;(require "(submod low.rkt untyped)") +;(#lang reader "scribble-custom/lp2.rkt" #:lang typed/racket) + +;; http://lists.racket-lang.org/users/archive/2015-January/065752.html +;; http://bugs.racket-lang.org/query/?cmd=view%20audit-trail&pr=14068 +;; &database=default +;(require (for-label (only-meta-in 0 typed/racket))) +;(provide (for-label (all-from-out typed/racket))) + +;; ==== remote images ==== +(provide remote-image) +(require (only-in scribble/core make-style) + (only-in scribble/html-properties alt-tag attributes)) +(define (remote-image src alt) + (cond-element + [html (elem + #:style + (make-style #f + (list (alt-tag "img") + (attributes + `((src . ,src) + (alt . ,alt))))))] + [else (elem)])) + +;; ==== hybrid footnotes/margin-note ==== +(provide note) +(require (only-in scriblib/footnote [note footnote]) + (only-in scribble/base margin-note) + (only-in scribble/core nested-flow style)) + +(define (note . args) + (cond-element + [html (element (style "refpara" '()) + (list (element (style "refcolumn" '()) + (list (element (style "refcontent" '()) + (list args))))))] + [else (apply footnote args)])) + +;; ==== ==== + +(require (for-syntax mzlib/etc)) +(define-syntax (doc-lib-setup stx) + ;(display (build-path (this-expression-source-directory) + ; (this-expression-file-name))) + #'setup-math) ;; NOTE: setup-math must be returned, not just called! + +(provide doc-lib-setup) + +;(require (only-in scribble/manual code)) +;(define-syntax-rule (tc . args) +; (code #:lang "typed/racket" . args)) +;(provide tc) + +;(require (only-in scribble/private/lp chunk CHUNK)) +;(provide chunk CHUNK) + + + + + + +;; Copied from the file: +;; /usr/local/racket-6.2.900.6/share/pkgs/scribble-lib/scribble/private/lp.rkt + +(require (for-syntax racket/base syntax/boundmap) + scribble/scheme scribble/decode scribble/manual + (except-in scribble/struct table)) + +(begin-for-syntax + ;; maps chunk identifiers to a counter, so we can distinguish multiple uses + ;; of the same name + (define chunk-numbers (make-free-identifier-mapping)) + (define (get-chunk-number id) + (free-identifier-mapping-get chunk-numbers id (lambda () #f))) + (define (inc-chunk-number id) + (free-identifier-mapping-put! chunk-numbers id + (+ 1 + (free-identifier-mapping-get chunk-numbers + id)))) + (define (init-chunk-number id) + (free-identifier-mapping-put! chunk-numbers id 2))) + +(define-syntax-rule (make-chunk chunk-id racketblock) + (define-syntax (chunk-id stx) + (syntax-case stx () + [(_ name expr (... ...)) + ;; no need for more error checking, using chunk for the code will do that + (identifier? #'name) + (let* ([n (get-chunk-number (syntax-local-introduce #'name))] + [str (symbol->string (syntax-e #'name))] + [tag (format "~a:~a" str (or n 1))]) + + (when n + (inc-chunk-number (syntax-local-introduce #'name))) + + (syntax-local-lift-expression #'(quote-syntax (a-chunk name + expr + (... ...)))) + + (with-syntax ([tag tag] + [str str] + [((for-label-mod (... ...)) (... ...)) + (map (lambda (expr) + (syntax-case expr (require) + [(require mod (... ...)) + (let loop + ([mods (syntax->list #'(mod (... ...)))]) + (cond + [(null? mods) null] + [else + (syntax-case (car mods) (for-syntax) + [(for-syntax x (... ...)) + (append (loop (syntax->list + #'(x (... ...)))) + (loop (cdr mods)))] + [x + (cons #'x (loop (cdr mods)))])]))] + [else null])) + (syntax->list #'(expr (... ...))))] + + [(rest (... ...)) (if n + #`((subscript #,(format "~a" n))) + #`())]) + #`(begin + #,@(if (null? (syntax-e #'(for-label-mod (... ...) (... ...)))) + #'() + #'((require (for-label for-label-mod (... ...) (... ...))))) + #,@(if n + #'() + #'((define-syntax name (make-element-id-transformer + (lambda (stx) #'(chunkref name)))) + (begin-for-syntax (init-chunk-number #'name)))) + ;(make-splice + ;(list (make-toc-element + ;#f + ;(list (elemtag '(chunk tag) + ; (bold (italic (racket name)) " ::="))) + ;(list (smaller (elemref '(chunk tag) #:underline? #f + ; str + ; rest (... ...))))) + (racket expr (... ...)))))]))) ;)) + +(make-chunk chunk2 racketblock) +(make-chunk CHUNK2 RACKETBLOCK) + +(define-syntax (chunkref stx) + (syntax-case stx () + [(_ id) + (identifier? #'id) + (with-syntax ([tag (format "~a:1" (syntax-e #'id))] + [str (format "~a" (syntax-e #'id))]) + #'(elemref '(chunk tag) #:underline? #f str))])) + +(provide chunk2 CHUNK2) + +(provide tc TC) +(define-syntax-rule (tc . rest) (chunk2 name . rest)) +(define-syntax-rule (TC . rest) (CHUNK2 name . rest)) diff --git a/forkmeongithub.rkt b/forkmeongithub.rkt new file mode 100644 index 00000000..f07e54de --- /dev/null +++ b/forkmeongithub.rkt @@ -0,0 +1,84 @@ +#lang racket + +(require scribble/manual + (only-in scribble/core make-style) + (only-in scribble/html-properties alt-tag attributes)) + +(provide forkongithub) + +(define css-code + #< + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/main.rkt b/main.rkt new file mode 100644 index 00000000..1fa4f453 --- /dev/null +++ b/main.rkt @@ -0,0 +1,4 @@ +#lang racket/base + +(require scribble-enhanced/manual-form) +(provide (all-from-out scribble-enhanced/manual-form)) diff --git a/manual-form.rkt b/manual-form.rkt new file mode 100644 index 00000000..445a68f1 --- /dev/null +++ b/manual-form.rkt @@ -0,0 +1,639 @@ +#lang scheme/base +;; Added #:result option to defform. +;; This file is mostly based on scribble-lib/scribble/private/manual-form.rkt +;; With pieces from scribble-lib/scribble/private/manual-proc.rkt +;; And pieces from scribble-lib/scribble/private/manual-scheme.rkt + +(require scribble/decode + scribble/struct + scribble/scheme + scribble/basic + scribble/manual-struct + scribble/private/qsloc + scribble/private/manual-utils + scribble/private/manual-vars + scribble/private/manual-scheme + scribble/private/manual-bind + scheme/list + syntax/parse/define + (only-in scribble/core + make-style + make-table-columns + make-nested-flow + [make-paragraph make-paragraph2] + nested-flow) + (for-syntax scheme/base + syntax/parse + syntax/srcloc + racket/syntax) + (for-label scheme/base)) + +(provide defform defform* defform/subs defform*/subs defform/none + defidform defidform/inline + specform specform/subs + specsubform specsubform/subs specspecsubform specspecsubform/subs + specsubform/inline + defsubform defsubform* + racketgrammar racketgrammar* + (rename-out [racketgrammar schemegrammar] + [racketgrammar* schemegrammar*]) + var svar + (for-syntax kind-kw id-kw link-target?-kw + literals-kw subs-kw contracts-kw)) + +(begin-for-syntax + (define-splicing-syntax-class kind-kw + #:description "#:kind keyword" + (pattern (~seq #:kind kind)) + (pattern (~seq) + #:with kind #'#f)) + + (define-splicing-syntax-class id-kw + #:description "#:id keyword" + (pattern (~seq #:id [defined-id:id defined-id-expr])) + (pattern (~seq #:id defined-id:id) + #:with defined-id-expr #'(quote-syntax defined-id)) + (pattern (~seq #:id [#f #f]) + #:with defined-id #'#f + #:with defined-id-expr #'#f) + (pattern (~seq) + #:with defined-id #'#f + #:with defined-id-expr #'#f)) + + (define-splicing-syntax-class link-target?-kw + #:description "#:link-target? keyword" + (pattern (~seq #:link-target? expr)) + (pattern (~seq) + #:with expr #'#t)) + + (define-splicing-syntax-class literals-kw + #:description "#:literals keyword" + (pattern (~seq #:literals (lit:id ...))) + (pattern (~seq) + #:with (lit ...) #'())) + + (define-splicing-syntax-class result-kw + #:description "#:literals keyword" + (pattern (~seq #:result r) + #:with maybe-result #'(r)) + (pattern (~seq) + #:with maybe-result #'())) + (define-splicing-syntax-class results-kw + #:description "#:literals keyword" + (pattern (~seq #:results (result ...)))) + + (define-splicing-syntax-class contracts-kw + #:description "#:contracts keyword" + (pattern (~seq #:contracts (~and cs ([contract-nonterm:id contract-expr] ...)))) + (pattern (~seq) + #:with (~and cs ((contract-nonterm contract-expr) ...)) #'())) + + (define-syntax-class grammar + #:description "grammar" + (pattern ([non-term-id:id non-term-form ...+] ...))) + + (define-splicing-syntax-class subs-kw + #:description "#:grammar keyword" + #:attributes (g (g.non-term-id 1) (g.non-term-form 2)) + (pattern (~seq #:grammar g:grammar)) + (pattern (~seq) #:with g:grammar #'())) + ) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Adjusted from manual-scheme.rkt +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(define-syntax-rule (define-/form* id base) + (define-syntax (id stx) + (syntax-case stx () + [(_ . a) + ;; Remove the context from any ellipsis in `a`: + (with-syntax ([a (strip-ellipsis-context #'a)]) + #'(base . a))]))) + +(define-for-syntax (strip-ellipsis-context a) + (define a-ellipsis (datum->syntax a '...)) + (let loop ([a a]) + (cond + [(identifier? a) + (if (free-identifier=? a a-ellipsis #f) + (datum->syntax #f '... a a) + a)] + [(syntax? a) + (datum->syntax a (loop (syntax-e a)) a a)] + [(pair? a) + (cons (loop (car a)) + (loop (cdr a)))] + [(vector? a) + (list->vector + (map loop (vector->list a)))] + [(box? a) + (box (loop (unbox a)))] + [(prefab-struct-key a) + => (lambda (k) + (apply make-prefab-struct + k + (loop (cdr (vector->list (struct->vector a))))))] + [else a]))) + +(define-/form* racketblock0/form* racketblock0) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; From manual-proc.rkt +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(define-syntax (result-contract stx) + (syntax-case stx (values) + [(_ (values c ...)) + #'(list (racketblock0 c) ...)] + [(_ c) + (if (string? (syntax-e #'c)) + (raise-syntax-error 'defproc + "expected a result contract, found a string" #'c) + #'(racketblock0 c))] + [(_) + #'#f])) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Adjusted from manual-proc.rkt +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(define (end result-contract) + (define res + (let ([res (result-contract)]) + (and res + (if (list? res) + ;; multiple results + (if (null? res) + 'nbsp + (let ([w (apply + (map block-width res))]) + (if (or (ormap table? res) (w . > . 40)) + (make-table + #f (map (lambda (fe) (list (make-flow (list fe)))) res)) + (make-table + #f + (list (let loop ([res res]) + (if (null? (cdr res)) + (list (make-flow (list (car res)))) + (list* (make-flow (list (car res))) + flow-spacer + (loop (cdr res)))))))))) + res)))) + (if res + (list flow-spacer (to-flow 'rarr) + flow-spacer (make-flow (list res))) + (list))) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(define-syntax (defform*/subs stx) + (syntax-parse stx + [(_ k:kind-kw lt:link-target?-kw d:id-kw l:literals-kw [spec spec1 ...] + (~optional results:results-kw) + g:grammar + c:contracts-kw + desc ...) + (with-syntax* ([defined-id (if (syntax-e #'d.defined-id) + #'d.defined-id + (syntax-case #'spec () + [(spec-id . _) #'spec-id]))] + [defined-id-expr (if (syntax-e #'d.defined-id-expr) + #'d.defined-id-expr + #'(quote-syntax defined-id))] + [(new-spec ...) + (for/list ([spec (in-list (syntax->list #'(spec spec1 ...)))]) + (let loop ([spec spec]) + (if (and (identifier? spec) + (free-identifier=? spec #'defined-id)) + (datum->syntax #'here '(unsyntax x) spec spec) + (syntax-case spec () + [(a . b) + (datum->syntax spec + (cons (loop #'a) (loop #'b)) + spec + spec)] + [id + (and (identifier? #'id) + (or (free-identifier=? #'id #'quote) + (free-identifier=? #'id #'unquote) + (free-identifier=? #'id #'quasiquote))) + (if (= (source-location-span #'id) 1) + (datum->syntax #'here + `(unsyntax ',(syntax-e #'id)) + spec + spec) + (datum->syntax #'here + `(unsyntax (RACKET ,(syntax-e #'id))) + spec + spec))] + [id + (and (identifier? #'id) + (or (free-identifier=? #'id #'syntax) + (free-identifier=? #'id #'unsyntax) + (free-identifier=? #'id #'quasisyntax))) + (if (= (source-location-span #'id) 2) + (datum->syntax #'here + `(unsyntax ',(syntax-e #'id)) + spec + spec) + (datum->syntax #'here + `(unsyntax (RACKET ,(syntax-e #'id))) + spec + spec))] + [_ spec]))))] + [(maybe-result ...) (if (attribute results) + #'(results.result ...) + (map (λ _ #'()) + (syntax->list #'(spec spec1 ...))))]) + #'(with-togetherable-racket-variables + (l.lit ...) + ([form [defined-id spec]] [form [defined-id spec1]] ... + [non-term (g.non-term-id g.non-term-form ...)] ...) + (*defforms k.kind lt.expr defined-id-expr + '(spec spec1 ...) + (list + (lambda (x) + (top-align + make-table + "prototype" + (list + (list (list (racketblock0/form* new-spec))) + (list (list (make-flow (top-align + make-table + "prototype" + (list (end (λ () (result-contract . maybe-result))))))))))) + ...) + '((g.non-term-id g.non-term-form ...) ...) + (list (list (lambda () (racket g.non-term-id)) + (lambda () (racketblock0/form g.non-term-form)) + ...) + ...) + (list (list (lambda () (racket c.contract-nonterm)) + (lambda () (racketblock0 c.contract-expr))) + ...) + (lambda () (list desc ...)))))])) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; From manual-proc +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(define top-align-styles (make-hash)) +(define (top-align make-table style-name cols) + (if (null? cols) + (make-table style-name null) + (let* ([n (length (car cols))] + [k (cons style-name n)]) + (make-table + (hash-ref top-align-styles + k + (lambda () + (define s + (make-style style-name + (list (make-table-columns (for/list ([i n]) + (make-style #f '(top))))))) + (hash-set! top-align-styles k s) + s)) + cols)))) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(define-syntax (defform* stx) + (syntax-parse stx + [(_ k:kind-kw lt:link-target?-kw d:id-kw l:literals-kw [spec ...] + (~optional r:results-kw) + subs:subs-kw c:contracts-kw desc ...) + (quasisyntax/loc stx + (defform*/subs #:kind k.kind + #:link-target? lt.expr + #:id [d.defined-id d.defined-id-expr] + #:literals (l.lit ...) + [spec ...] + #,@(if (attribute r) #'(#:results [r.result ...]) #'()) + subs.g #:contracts c.cs desc ...))])) + +(define-syntax (defform stx) + (syntax-parse stx + [(_ k:kind-kw lt:link-target?-kw d:id-kw l:literals-kw spec + r:result-kw + subs:subs-kw c:contracts-kw desc ...) + (syntax/loc stx + (defform*/subs #:kind k.kind + #:link-target? lt.expr + #:id [d.defined-id d.defined-id-expr] + #:literals (l.lit ...) + [spec] #:results [r.maybe-result] subs.g #:contracts c.cs desc ...))])) + +(define-syntax (defform/subs stx) + (syntax-parse stx + [(_ k:kind-kw lt:link-target?-kw d:id-kw l:literals-kw spec r:result-kw subs desc ...) + (syntax/loc stx + (defform*/subs #:kind k.kind + #:link-target? lt.expr + #:id [d.defined-id d.defined-id-expr] + #:literals (l.lit ...) + [spec] #:results [r.maybe-result] subs desc ...))])) + +(define-syntax (defform/none stx) + (syntax-parse stx + [(_ k:kind-kw lt:link-target?-kw l:literals-kw spec subs:subs-kw c:contracts-kw desc ...) + (syntax/loc stx + (with-togetherable-racket-variables + (l.lit ...) + ([form/none spec] + [non-term (subs.g.non-term-id subs.g.non-term-form ...)] ...) + (*defforms k.kind lt.expr #f + '(spec) + (list (lambda (ignored) (racketblock0/form spec))) + '((subs.g.non-term-id subs.g.non-term-form ...) ...) + (list (list (lambda () (racket subs.g.non-term-id)) + (lambda () (racketblock0/form subs.g.non-term-form)) + ...) + ...) + (list (list (lambda () (racket c.contract-nonterm)) + (lambda () (racketblock0 c.contract-expr))) + ...) + (lambda () (list desc ...)))))])) + +(define-syntax (defidform/inline stx) + (syntax-case stx (unsyntax) + [(_ id) + (identifier? #'id) + #'(defform-site (quote-syntax id))] + [(_ (unsyntax id-expr)) + #'(defform-site id-expr)])) + +(define-syntax (defidform stx) + (syntax-parse stx + [(_ k:kind-kw lt:link-target?-kw spec-id desc ...) + #'(with-togetherable-racket-variables + () + () + (*defforms k.kind lt.expr (quote-syntax/loc spec-id) + '(spec-id) + (list (lambda (x) (make-omitable-paragraph (list x)))) + null + null + null + (lambda () (list desc ...))))])) + +(define (into-blockquote s) + (make-blockquote "leftindent" + (if (splice? s) + (flow-paragraphs (decode-flow (splice-run s))) + (list s)))) + +(define-syntax (defsubform stx) + (syntax-case stx () + [(_ . rest) #'(into-blockquote (defform . rest))])) + +(define-syntax (defsubform* stx) + (syntax-case stx () + [(_ . rest) #'(into-blockquote (defform* . rest))])) + +(define-syntax (spec?form/subs stx) + (syntax-parse stx + [(_ has-kw? l:literals-kw (~or (~seq #:unwrap (spec ...)) + (~and (~seq spec0) (~seq spec ...))) + g:grammar + c:contracts-kw + desc ...) + #:with spec* (or (attribute spec0) #'(spec ...)) + (syntax/loc stx + (with-racket-variables + (l.lit ...) + ([form/maybe (has-kw? spec*)] + [non-term (g.non-term-id g.non-term-form ...)] ...) + (*specsubform 'spec* '(l.lit ...) (lambda () (racketblock0/form* spec ...)) + '((g.non-term-id g.non-term-form ...) ...) + (list (list (lambda () (racket g.non-term-id)) + (lambda () (racketblock0/form g.non-term-form)) + ...) + ...) + (list (list (lambda () (racket c.contract-nonterm)) + (lambda () (racketblock0 c.contract-expr))) + ...) + (lambda () (list desc ...)))))])) + +(begin-for-syntax + (define-splicing-syntax-class unwrappable-spec + (pattern (~seq #:unwrap s) #:with (m-u-spec ...) #'(#:unwrap s)) + (pattern (~seq spec) #:with (m-u-spec ...) #'(spec)))) + +(define-syntax (specsubform stx) + (syntax-parse stx + [(_ l:literals-kw :unwrappable-spec subs:subs-kw c:contracts-kw desc ...) + (syntax/loc stx + (spec?form/subs #f #:literals (l.lit ...) m-u-spec ... subs.g #:contracts c.cs desc ...))])) + +(define-syntax (specsubform/subs stx) + (syntax-parse stx + [(_ l:literals-kw :unwrappable-spec g:grammar desc ...) + (syntax/loc stx + (spec?form/subs #f #:literals (l.lit ...) m-u-spec ... + ([g.non-term-id g.non-term-form ...] ...) + desc ...))])) + +(define-simple-macro (specspecsubform :unwrappable-spec desc ...) + (make-blockquote "leftindent" (list (specsubform m-u-spec ... desc ...)))) + +(define-simple-macro (specspecsubform/subs :unwrappable-spec subs desc ...) + (make-blockquote "leftindent" (list (specsubform/subs m-u-spec ... subs desc ...)))) + +(define-syntax (specform stx) + (syntax-parse stx + [(_ l:literals-kw spec subs:subs-kw c:contracts-kw desc ...) + (syntax/loc stx + (spec?form/subs #t #:literals (l.lit ...) spec subs.g #:contracts c.cs desc ...))])) + +(define-syntax (specform/subs stx) + (syntax-parse stx + [(_ l:literals-kw spec g:grammar + desc ...) + (syntax/loc stx + (spec?form/subs #t #:literals (l.lit ...) spec ([g.non-term-id g.non-term-form ...] ...) + desc ...))])) + +(define-syntax-rule (specsubform/inline spec desc ...) + (with-racket-variables + () + ([form/maybe (#f spec)]) + (*specsubform 'spec null #f null null null (lambda () (list desc ...))))) + +(define-syntax racketgrammar + (syntax-rules () + [(_ #:literals (lit ...) id clause ...) + (racketgrammar* #:literals (lit ...) [id clause ...])] + [(_ id clause ...) (racketgrammar #:literals () id clause ...)])) + +(define-syntax racketgrammar* + (syntax-rules () + [(_ #:literals (lit ...) [id clause ...] ...) + (with-racket-variables + (lit ...) + ([non-term (id clause ...)] ...) + (*racketgrammar '(lit ...) + '(id ... clause ... ...) + (lambda () + (list (list (racket id) + (racketblock0/form clause) ...) + ...))))] + [(_ [id clause ...] ...) + (racketgrammar* #:literals () [id clause ...] ...)])) + +(define-syntax-rule (var id) + (*var 'id)) + +(define-syntax-rule (svar id) + (*var 'id)) + + +(define (meta-symbol? s) (memq s '(... ...+ ?))) + +(define (defform-site kw-id) + (let ([target-maker (id-to-form-target-maker kw-id #t)]) + (define-values (content ref-content) (definition-site (syntax-e kw-id) kw-id #t)) + (if target-maker + (target-maker + content + (lambda (tag) + (make-toc-target2-element + #f + (if kw-id + (make-index-element + #f content tag + (list (datum-intern-literal (symbol->string (syntax-e kw-id)))) + (list ref-content) + (with-exporting-libraries + (lambda (libs) + (make-form-index-desc (syntax-e kw-id) + libs)))) + content) + tag + ref-content))) + content))) + +(define (*defforms kind link? kw-id forms form-procs subs sub-procs contract-procs content-thunk) + (parameterize ([current-meta-list '(... ...+)]) + (make-box-splice + (cons + (make-blockquote + vertical-inset-style + (list + (make-table + boxed-style + (append + (for/list ([form (in-list forms)] + [form-proc (in-list form-procs)] + [i (in-naturals)]) + (list + ((if (zero? i) (add-background-label (or kind "syntax")) values) + ;(list + ;(make-nested-flow (make-style #f '()) + (list + ((or form-proc + (lambda (x) + (make-omitable-paragraph + (list (to-element `(,x . ,(cdr form))))))) + (and kw-id + (if (eq? form (car forms)) + (if link? + (defform-site kw-id) + (to-element #:defn? #t kw-id)) + (to-element #:defn? #t kw-id)))))))) + (if (null? sub-procs) + null + (list (list flow-empty-line) + (list (make-flow + (list (let ([l (map (lambda (sub) + (map (lambda (f) (f)) sub)) + sub-procs)]) + (*racketrawgrammars "specgrammar" + (map car l) + (map cdr l)))))))) + (make-contracts-table contract-procs))))) + (content-thunk))))) + +(define (*specsubform form lits form-thunk subs sub-procs contract-procs content-thunk) + (parameterize ([current-meta-list '(... ...+)]) + (make-blockquote + "leftindent" + (cons + (make-blockquote + vertical-inset-style + (list + (make-table + boxed-style + (cons + (list + (make-flow + (list + (if form-thunk + (form-thunk) + (make-omitable-paragraph (list (to-element form))))))) + (append + (if (null? sub-procs) + null + (list (list flow-empty-line) + (list (make-flow + (list (let ([l (map (lambda (sub) + (map (lambda (f) (f)) sub)) + sub-procs)]) + (*racketrawgrammars "specgrammar" + (map car l) + (map cdr l)))))))) + (make-contracts-table contract-procs)))))) + (flow-paragraphs (decode-flow (content-thunk))))))) + +(define (*racketrawgrammars style nonterms clauseses) + (make-table + `((valignment baseline baseline baseline baseline baseline) + (alignment right left center left left) + (style ,style)) + (cdr + (append-map + (lambda (nonterm clauses) + (list* + (list flow-empty-line flow-empty-line flow-empty-line + flow-empty-line flow-empty-line) + (list (to-flow nonterm) flow-empty-line (to-flow "=") flow-empty-line + (make-flow (list (car clauses)))) + (map (lambda (clause) + (list flow-empty-line flow-empty-line + (to-flow "|") flow-empty-line + (make-flow (list clause)))) + (cdr clauses)))) + nonterms clauseses)))) + +(define (*racketrawgrammar style nonterm clause1 . clauses) + (*racketrawgrammars style (list nonterm) (list (cons clause1 clauses)))) + +(define (*racketgrammar lits s-expr clauseses-thunk) + (let ([l (clauseses-thunk)]) + (*racketrawgrammars #f + (map (lambda (x) + (make-element #f + (list (hspace 2) + (car x)))) + l) + (map cdr l)))) + +(define (*var id) + (to-element (*var-sym id))) + +(define (*var-sym id) + (string->symbol (format "_~a" id))) + +(define (make-contracts-table contract-procs) + (if (null? contract-procs) + null + (append + (list (list flow-empty-line)) + (list (list (make-flow + (map (lambda (c) + (make-table + "argcontract" + (list + (list (to-flow (hspace 2)) + (to-flow ((car c))) + flow-spacer + (to-flow ":") + flow-spacer + (make-flow (list ((cadr c)))))))) + contract-procs))))))) diff --git a/math.rkt b/math.rkt new file mode 100644 index 00000000..086d21cc --- /dev/null +++ b/math.rkt @@ -0,0 +1,38 @@ +#lang at-exp racket + +(provide setup-math) + +(require scribble/html-properties + scribble/latex-properties + scribble/base + scribble/core) + +(require scriblib/render-cond) + +(require "unicode-chars.sty.rkt") + +(define setup-math + (cond-element + [(and (or html)) + (elem #:style (style #f (list)) '())] + [latex + (elem #:style (style + #f (list (tex-addition (string->bytes/utf-8 @string-append{ +%\overfullrule=2cm +\usepackage[scaled=0.7]{beramono} +\usepackage{newunicodechar} +%\newunicodechar{ᵢ}{\ensuremath{_1}} + +\usepackage{xcolor} +\hypersetup{ + unicode=true, + colorlinks=true, + linkcolor={red!50!white!50!black}, + citecolor={blue!50!black}, + urlcolor={blue!80!black}, +} + +@unicode-chars +})))) + "")] + [else (elem)])) diff --git a/scribblings/scribble-enhanced-example.lp2.rkt b/scribblings/scribble-enhanced-example.lp2.rkt new file mode 100644 index 00000000..82f9d36f --- /dev/null +++ b/scribblings/scribble-enhanced-example.lp2.rkt @@ -0,0 +1,64 @@ +#lang scribble/lp2 +@(require scribble-enhanced/doc) +@doc-lib-setup + +@title[#:style manual-doc-style]{Implementation of structures} + +@;Racket is distributed with implementations of many SRFIs, most of +@;which can be implemented as libraries. To import the bindings of SRFI +@;@math{n}, use +@; +@;@racketblock[ +@;(require @#,elem{@racketidfont{srfi/}@math{n}}) +@;] + +@section{A section} + +In section @secref{doc/example|foo} we present, blah blah. + +@subsection[#:tag "doc/example|foo"]{My subsection} + +@;Works only with HTML, as \class is not defined. TODO: define it. +@;@$${\frac{\href{//jsmaniac.github.io}{2x}}{\class{some-css-class}{x^2}}} + + +@(colorize (filled-ellipse 30 15) "blue") +@; Line comment + +Blah @math{n}, as described by M@._ Foo@.__ +@racketblock[ + (require @#,elem{@racketidfont{srfi/}@math{n}})] + +@(define to-insert 42) +@chunk[ + ;(displayln #,to-insert) ;; Should work. + (provide some-ident) + + + (module* test racket + (require (submod "..")) + (require rackunit) + (check-equal? (some-ident) "foo"))] + +@CHUNK[ + (define (some-ident) + (syntax-e #`#,"foo"))] + +@itemlist[ + @item{Item 1} + @item{Item 2}] + +It would be nice to be able to alter existing chunks, by inserting stuff later, +for example: + +@chunk[ + (define-syntax-rule (double x) + (+ x x))] + +But we would actually want: + +@chunk[ + (define-syntax-rule (double x) -- should be greyed out + (let ((x-cache x)) + (+ x-cache x-cache))) -- everything except the changed bits should + -- be greyed out] diff --git a/scribblings/scribble-enhanced-template.lp2.rkt b/scribblings/scribble-enhanced-template.lp2.rkt new file mode 100644 index 00000000..007f2780 --- /dev/null +++ b/scribblings/scribble-enhanced-template.lp2.rkt @@ -0,0 +1,111 @@ +#lang scribble/lp2 +@; TODO: use hyper-literate language instead. +@(require scribble-enhanced/doc) +@doc-lib-setup + +@title[#:style manual-doc-style]{Life, the Universe and Everything.} + +@(table-of-contents) + +@section{Introduction} + +@chunk[ + (define lue 42)] + +Here is a macro: + +@CHUNK[ + (define-for-syntax mymacro-tmp + (syntax-rules () [(_ a b) (let ((b 1)) a)])) + (define-syntax (mymacro-stx stx) #`'#,(mymacro-tmp stx)) + (define-syntax mymacro mymacro-tmp)] + +We can use it like this: + +@chunk[ + (mymacro (+ x 3) x)] + +@(begin + (require (for-syntax racket/base)) + (define-syntax (if<6.4 stx) + (syntax-case stx () + [(_ lt ge) + (if (or (regexp-match #px"^6(\\.[0123](\\..*|)|)$" (version)) + (regexp-match #px"^[123245]\\..*$" (version))) + #'lt + #'ge)])) + (define-syntax-rule (skip<6.4 . rest) (if<6.4 (begin) (begin . rest)))) + +@skip<6.4{ + Which expands to (requires Racket ≥ 6.4 and a bit of set-up boilerplate to have + the output in scribble, see + @url{http://lists.racket-lang.org/users/archive/2014-December/065175.html}): + @(begin + (require syntax/location scribble/example) + (define res-mod-name + (resolved-module-path-name + (module-path-index-resolve + (module-path-index-join '(submod ".." main) + (variable-reference->module-path-index + (#%variable-reference)))))) + (define evaluator (make-base-eval #:lang 'typed/racket)) + (evaluator + #`(begin + (require/typed racket/enter + [dynamic-enter! (->* (Module-Path) + (#:re-require-enter? Any) + Void)]) + (dynamic-require (cast '#,(cons 'submod res-mod-name) Module-Path) #f) + (dynamic-enter! (cast '#,(cons 'submod res-mod-name) Module-Path) + #:re-require-enter? #f)))) + + @examples[#:eval evaluator #:result-only + (mymacro-stx (+ x 3) x) + #;(begin + (require (for-syntax racket/pretty)) + (begin-for-syntax + (pretty-write + (syntax->datum + #'(mymacro-tmp (+ x 3) x)))))] + + The code above should show the expanded code, i.e:} + +@if<6.4[ + @list{With Racket ≥ 6.4, it is possible to automatically compute the expanded + code, and show it. The result would be:} + @list{}] + +@chunk[ + (let ((x 1)) (+ x 3))] + +@chunk[ + (check-equal? lue 42)] + +@section{Conclusion} + +@chunk[ + (module main typed/racket + (require (for-syntax syntax/parse + racket/syntax + #;phc-toolkit/untyped) + #;phc-toolkit/untyped) + (provide lue) + + + )] + +@chunk[ + (module* test typed/racket + (require (submod "..") + typed/rackunit) + + )] + +@chunk[<*> + (begin + + + (require 'main) + (provide (all-from-out 'main)) + + )] \ No newline at end of file diff --git a/scribblings/scribble-enhanced.scrbl b/scribblings/scribble-enhanced.scrbl new file mode 100644 index 00000000..81c07764 --- /dev/null +++ b/scribblings/scribble-enhanced.scrbl @@ -0,0 +1,85 @@ +#lang scribble/manual +@require[@for-label[scribble-enhanced + racket/base] + scribble-enhanced] + +@title{Scribble Enhanced} +@author{Georges Dupéron} + +@defmodule[scribble-enhanced] + +@section{@racket[defform] enhancements} + +@subsection{Easy rendering of quotes and syntax reader abbreviations} + +The six common reader abbreviations are rendered as +expected, using a heuristic on source locations (so that +@tt{#`} renders as @tt{#`} and not @tt{quasisyntax} when the +source location span is exactly two characters, for +example). + +@racketblock[ + @defform[#:kind "example" + (example-1 a + #'(b arg …) + #`(c arg …) + ((unsyntax 'unsyntax) (d arg …)) + 'd + `e + ,f + (@#,RACKET[syntax] (e arg …)) + (@#,RACKET[quasisyntax] (f arg …)) + (@#,RACKET[unsyntax] (g arg …)) + (@#,RACKET[quote] d) + (@#,RACKET[quasiquote] e) + (@#,RACKET[unquote] f))]] + +The above example renders as (with reader abbreviations for +the first six, but not for the last six): + +@nested[#:style 'code-inset]{ + @defform[#:kind "example" + (example-1 a + #'(b arg …) + #`(c arg …) + #,(d arg …) + 'd + `e + ,f + (syntax (a arg …)) + (quasisyntax (b arg …)) + (unsyntax (c arg …)) + (quote d) + (quasiquote e) + (unquote f))] +} + +@subsubsection{Escaping from @racket[defform]} + +Escaping from defform using @racket[UNSYNTAX] is not +implemented yet. + +@subsection{@racket[#:result] for @racket[defform]} + +@racketblock[ + @defform[#:kind "example" + (example-2 a #'([b c] ...)) + #:result void? + #:contracts ([a port?] + [b number?] + [c string?])]{ + Example description + }] + +The code above renders as follows: + +@nested[#:style 'code-inset]{ + @defform[#:kind "example" + (example-2 a #'([b c] ...)) + #:result void? + #:contracts ([a port?] + [b number?] + [c string?])]{ + Example description + } +} \ No newline at end of file diff --git a/unicode-chars.sty.rkt b/unicode-chars.sty.rkt new file mode 100644 index 00000000..9cbc1c6c --- /dev/null +++ b/unicode-chars.sty.rkt @@ -0,0 +1,229 @@ +#lang at-exp racket +(provide unicode-chars) +(define unicode-chars + @string-append|<<<{ +\makeatletter +% Must be loaded after MnSymbol!!! MnSymbol improperly defines × and ¬ in such a +% way that they don't work in math mode. +% definition of some characters, for use with +% \usepackage[utf8]{inputenc} +% \usepackage[T1]{fontenc} +% Author: Christoph Lange +% Some math characters taken from John Wickerson's MathUnicode.sty +% (http://tex.stackexchange.com/questions/110042/ +% entering-unicode-math-symbols-into-latex-direct-from-keyboard-on-a-mac) +% https://github.com/clange/latex +\NeedsTeXFormat{LaTeX2e}[1999/12/01] +\ProvidesPackage{unicode-chars}[2013/10/08] + +%\DeclareUnicodeCharacter{00A0}{~}% +%\DeclareUnicodeCharacter{00A3}{\pounds}% £ +%\DeclareUnicodeCharacter{00AC}{\ensuremath{\neg}} ¬ +%\DeclareUnicodeCharacter{00AE}{\textsuperscript{\textregistered}}%® +%\DeclareUnicodeCharacter{00AF}{\ensuremath{^-}}% ¯ +%\DeclareUnicodeCharacter{00D7}{\ensuremath{\times}}% × + +%%%%%%%%%%%%%%%%%%%%%%%%% vvv % NO-BREAK SPACE here (unicode 00A0) +\catcode`\^^a0=13\relax\def {~}% " " (nbsp) +\catcode`\^^a3=13\relax\def£{\pounds}% £ +\catcode`\^^ae=13\relax\def®{\textsuperscript{\textregistered}}% ® +% macron: overline, overbar +\catcode`\^^af=13\relax\def¯{\ensuremath{^-}}% ¯ % macron +% \catcode`\^^f1=13\relax\defñ{\~{n}}% ñ +% Declared by MnSymbol: +% \catcode`\^^d7=13\relax\def×{\ensuremath{\times}}% × +% \catcode`\^^ac=13\relax\def¬{\ensuremath{\neg}}\relax% ¬ + +\DeclareUnicodeCharacter{00F1}{{\ifmmode\tilde{n}\else\~{n}\fi}} +% Declared by MnSymbol: +\DeclareUnicodeCharacter{00D7}{\ensuremath{\times}} +\DeclareUnicodeCharacter{00AC}{\ensuremath{\neg}} + +\DeclareUnicodeCharacter{0101}{\=a}% ā +\DeclareUnicodeCharacter{0123}{\c g}% ģ +\DeclareUnicodeCharacter{0130}{\. I}% İ +\DeclareUnicodeCharacter{0146}{\c n}% ņ +\DeclareUnicodeCharacter{016B}{\=u}% ū +\DeclareUnicodeCharacter{03B1}{\ensuremath{\alpha}}% α +\DeclareUnicodeCharacter{03B4}{\ensuremath{\delta}}% δ +\DeclareUnicodeCharacter{0394}{\ensuremath{\Delta}}% Δ +\DeclareUnicodeCharacter{03F5}{\ensuremath{\epsilon}}% ϵ +\DeclareUnicodeCharacter{03B5}{\ensuremath{\varepsilon}}% ε +\DeclareUnicodeCharacter{0395}{\ensuremath{\Epsilon}}% Ε +\DeclareUnicodeCharacter{03BB}{\ensuremath{\lambda}}% λ +\DeclareUnicodeCharacter{03C1}{\ensuremath{\rho}}% ρ +\DeclareUnicodeCharacter{03A1}{\ensuremath{\Rho}}% Ρ +\DeclareUnicodeCharacter{2190}{\ensuremath{\leftarrow}}% ← +\DeclareUnicodeCharacter{2192}{\ensuremath{\rightarrow}}% → +% 2192: \textrightarrow is not available in all fonts, +% and we need the right arrow in math mode +\DeclareUnicodeCharacter{2193}{\ensuremath{\downarrow}}% ↓ +\DeclareUnicodeCharacter{2194}{\ensuremath{\leftrightarrow}}% ↔ +\DeclareUnicodeCharacter{21A6}{\ensuremath{\mapsto}}% ↦ +\DeclareUnicodeCharacter{21C0}{\ensuremath{\rightharpoonup}}% ⇀ +\DeclareUnicodeCharacter{21D2}{\ensuremath{\Rightarrow}}% ⇒ +% Georges — added \operatorname{} in ∀ . +\DeclareUnicodeCharacter{2200}{\ensuremath{\operatorname{\forall}}}% ∀ +\DeclareUnicodeCharacter{2203}{\ensuremath{\exists}}% ∃ +\DeclareUnicodeCharacter{2208}{\ensuremath{\in}}% ∈ +\DeclareUnicodeCharacter{2209}{\ensuremath{\not\in}}% ∉ +\DeclareUnicodeCharacter{2211}{\ensuremath{\sum}}% ∑ +\DeclareUnicodeCharacter{220F}{\ensuremath{\prod}}% ∏ +\DeclareUnicodeCharacter{2218}{\ensuremath{\circ}}% ∘ +\DeclareUnicodeCharacter{2227}{\ensuremath{\mathbin{\wedge}}}% ∧ +\DeclareUnicodeCharacter{2228}{\ensuremath{\mathbin{\vee}}}% ∨ +\DeclareUnicodeCharacter{2229}{\ensuremath{\mathbin{\cap}}}% ∩ +\DeclareUnicodeCharacter{222A}{\ensuremath{\mathbin{\cup}}}% ∪ +\DeclareUnicodeCharacter{228D}{\ensuremath{\mathbin{\cupdot}}}% ⊍ +\DeclareUnicodeCharacter{228E}{\ensuremath{\mathbin{\uplus}}}% ⊎ +%\DeclareUnicodeCharacter{2237}{\ensuremath{::}}% ∷ +% 2237: not sure that's a good way to render this symbol +\DeclareUnicodeCharacter{2248}{\ensuremath{\approx}}% ≈ +\DeclareUnicodeCharacter{2260}{\ensuremath{\ne}}% ≠ +\DeclareUnicodeCharacter{2261}{\ensuremath{\equiv}}% ≡ +\DeclareUnicodeCharacter{2264}{\ensuremath{\le}}% ≤ +\DeclareUnicodeCharacter{2265}{\ensuremath{\ge}}% ≥ +\DeclareUnicodeCharacter{2286}{\ensuremath{\subseteq}}% ⊆ +\DeclareUnicodeCharacter{2287}{\ensuremath{\supseteq}}% ⊇ +\DeclareUnicodeCharacter{219D}{\ensuremath{\leadsto}}% ↝ +\@ifpackageloaded{MnSymbol}{% +\DeclareUnicodeCharacter{2295}{\ensuremath{\oplus}}% ⊕ +\DeclareUnicodeCharacter{2296}{\ensuremath{\ominus}}% ⊖ +}{} +\DeclareUnicodeCharacter{22C0}{\ensuremath{\bigwedge}}% ⋀ +\DeclareUnicodeCharacter{22C0}{\ensuremath{\bigcupdot}}% ⋀ +\DeclareUnicodeCharacter{22C1}{\ensuremath{\biguplus}}% ⋁ +\DeclareUnicodeCharacter{22C2}{\ensuremath{\bigcap}}% ⋂ +\DeclareUnicodeCharacter{22C3}{\ensuremath{\bigcup}}% ⋃ +\DeclareUnicodeCharacter{2A03}{\ensuremath{\bigcupdot}}% ⨃ +\DeclareUnicodeCharacter{2A04}{\ensuremath{\biguplus}}% ⨄ +\DeclareUnicodeCharacter{25CB}{\ensuremath{\ocircle}}% ○ +\@ifpackageloaded{MnSymbol}{% +\DeclareUnicodeCharacter{2605}{\ensuremath{\filledlargestar}}% ★ +}{} +\DeclareUnicodeCharacter{2713}{\ensuremath{\checkmark}}% ✓ +\DeclareUnicodeCharacter{27F6}{\ensuremath{\longrightarrow}}% ⟶ +\DeclareUnicodeCharacter{27F7}{\ensuremath{\longleftrightarrow}}% ⟷ +\DeclareUnicodeCharacter{27F9}{\ensuremath{\Longrightarrow}}% ⟹ +% +% Additions by Georges Dupéron +\DeclareUnicodeCharacter{2237}{\ensuremath{\dblcolon}}% ∷ +\DeclareUnicodeCharacter{228F}{\ensuremath{\sqsubset}}% ⊏ +\DeclareUnicodeCharacter{2290}{\ensuremath{\sqsubset}}% ⊐ +\DeclareUnicodeCharacter{2291}{\ensuremath{\sqsubseteq}}% ⊑ +\DeclareUnicodeCharacter{2292}{\ensuremath{\sqsupseteq}}% ⊒ +\DeclareUnicodeCharacter{2293}{\ensuremath{\sqcap}}% ⊓ +\DeclareUnicodeCharacter{2294}{\ensuremath{\sqcup}}% ⊔ +% +\usepackage{graphicx}% +\providecommand{\bigsqcap}{% + \mathop{% + \mathpalette\@updown\bigsqcup + }% +} +\newcommand*{\@updown}[2]{% + \rotatebox[origin=c]{180}{$\m@th#1#2$}% +} +\DeclareUnicodeCharacter{2A05}{\ensuremath{\bigsqcap}}% ⨅ +\DeclareUnicodeCharacter{2A06}{\ensuremath{\bigsqcup}}% ⨆ +\DeclareUnicodeCharacter{2080}{\ensuremath{_0}}% ₀ +\DeclareUnicodeCharacter{2081}{\ensuremath{_1}}% ₁ +\DeclareUnicodeCharacter{2082}{\ensuremath{_2}}% ₂ +\DeclareUnicodeCharacter{2083}{\ensuremath{_3}}% ₃ +\DeclareUnicodeCharacter{2084}{\ensuremath{_4}}% ₄ +\DeclareUnicodeCharacter{2085}{\ensuremath{_5}}% ₅ +\DeclareUnicodeCharacter{2086}{\ensuremath{_6}}% ₆ +\DeclareUnicodeCharacter{2087}{\ensuremath{_7}}% ₇ +\DeclareUnicodeCharacter{2088}{\ensuremath{_8}}% ₈ +\DeclareUnicodeCharacter{2089}{\ensuremath{_9}}% ₉ +\DeclareUnicodeCharacter{208A}{\ensuremath{_+}}% ₊ +\DeclareUnicodeCharacter{208B}{\ensuremath{_-}}% ₋ +\DeclareUnicodeCharacter{208C}{\ensuremath{_=}}% ₌ +\DeclareUnicodeCharacter{208D}{\ensuremath{_(}}% ₍ +\DeclareUnicodeCharacter{208E}{\ensuremath{_)}}% ₎ +\DeclareUnicodeCharacter{2098}{\ensuremath{_m}}% ₘ +\DeclareUnicodeCharacter{2099}{\ensuremath{_n}}% ₙ +\DeclareUnicodeCharacter{1D62}{\ensuremath{_i}}% ᵢ +\DeclareUnicodeCharacter{2C7C}{\ensuremath{_j}}% ⱼ +% +\DeclareUnicodeCharacter{2070}{\ensuremath{^0}}% ⁰ +%\DeclareUnicodeCharacter{00B9}{\ensuremath{^1}}% ¹ +%\DeclareUnicodeCharacter{00B2}{\ensuremath{^2}}% ² +%\DeclareUnicodeCharacter{00B3}{\ensuremath{^3}}% ³ +\DeclareUnicodeCharacter{2074}{\ensuremath{^4}}% ⁴ +\DeclareUnicodeCharacter{2075}{\ensuremath{^5}}% ⁵ +\DeclareUnicodeCharacter{2076}{\ensuremath{^6}}% ⁶ +\DeclareUnicodeCharacter{2077}{\ensuremath{^7}}% ⁷ +\DeclareUnicodeCharacter{2078}{\ensuremath{^8}}% ⁸ +\DeclareUnicodeCharacter{2079}{\ensuremath{^9}}% ⁹ +\DeclareUnicodeCharacter{207A}{\ensuremath{^+}}% ⁺ +\DeclareUnicodeCharacter{207B}{\ensuremath{^-}}% ⁻ +\DeclareUnicodeCharacter{207C}{\ensuremath{^=}}% ⁼ +\DeclareUnicodeCharacter{207D}{\ensuremath{^(}}% ⁽ +\DeclareUnicodeCharacter{207E}{\ensuremath{^)}}% ⁾ +\DeclareUnicodeCharacter{207F}{\ensuremath{^n}}% ⁿ +\DeclareUnicodeCharacter{2071}{\ensuremath{^i}}% ⁱ +%s +% \DeclareUnicodeCharacter{2026}{\ensuremath{\dots}}% … + +% Generated from ~/.XCompose using: +% cat /tmp/cal.txt | cut -d '"' -f 2- | tr '"' ' ' | cut -d ' ' -f 1,6 \ +% | while IFS=' ' read a b; do +% echo -n "\\DeclareUnicodeCharacter{$(printf "%X" "'$a")}" +% echo "{\\\\ensuremath{\\mathcal{$b}}}% $a"; +% done + +\DeclareUnicodeCharacter{1D49C}{\ensuremath{\mathcal{A}}}% 𝒜 +\DeclareUnicodeCharacter{212C}{\ensuremath{\mathcal{B}}}% ℬ +\DeclareUnicodeCharacter{1D49E}{\ensuremath{\mathcal{C}}}% 𝒞 +\DeclareUnicodeCharacter{1D49F}{\ensuremath{\mathcal{D}}}% 𝒟 +\DeclareUnicodeCharacter{2130}{\ensuremath{\mathcal{E}}}% ℰ +\DeclareUnicodeCharacter{2131}{\ensuremath{\mathcal{F}}}% ℱ +\DeclareUnicodeCharacter{1D4A2}{\ensuremath{\mathcal{G}}}% 𝒢 +\DeclareUnicodeCharacter{210B}{\ensuremath{\mathcal{H}}}% ℋ +\DeclareUnicodeCharacter{2110}{\ensuremath{\mathcal{I}}}% ℐ +\DeclareUnicodeCharacter{1D4A5}{\ensuremath{\mathcal{J}}}% 𝒥 +\DeclareUnicodeCharacter{1D4A6}{\ensuremath{\mathcal{K}}}% 𝒦 +\DeclareUnicodeCharacter{2112}{\ensuremath{\mathcal{L}}}% ℒ +\DeclareUnicodeCharacter{2133}{\ensuremath{\mathcal{M}}}% ℳ +\DeclareUnicodeCharacter{1D4A9}{\ensuremath{\mathcal{N}}}% 𝒩 +\DeclareUnicodeCharacter{1D4AA}{\ensuremath{\mathcal{O}}}% 𝒪 +\DeclareUnicodeCharacter{1D4AB}{\ensuremath{\mathcal{P}}}% 𝒫 +\DeclareUnicodeCharacter{1D4AC}{\ensuremath{\mathcal{Q}}}% 𝒬 +\DeclareUnicodeCharacter{211B}{\ensuremath{\mathcal{R}}}% ℛ +\DeclareUnicodeCharacter{1D4AE}{\ensuremath{\mathcal{S}}}% 𝒮 +\DeclareUnicodeCharacter{1D4AF}{\ensuremath{\mathcal{T}}}% 𝒯 +\DeclareUnicodeCharacter{1D4B0}{\ensuremath{\mathcal{U}}}% 𝒰 +\DeclareUnicodeCharacter{1D4B1}{\ensuremath{\mathcal{V}}}% 𝒱 +\DeclareUnicodeCharacter{1D4B2}{\ensuremath{\mathcal{W}}}% 𝒲 +\DeclareUnicodeCharacter{1D4B3}{\ensuremath{\mathcal{X}}}% 𝒳 +\DeclareUnicodeCharacter{1D4B4}{\ensuremath{\mathcal{Y}}}% 𝒴 +\DeclareUnicodeCharacter{1D4B5}{\ensuremath{\mathcal{Z}}}% 𝒵 +\DeclareUnicodeCharacter{1D4B6}{\ensuremath{\mathcal{a}}}% 𝒶 +\DeclareUnicodeCharacter{1D4B7}{\ensuremath{\mathcal{b}}}% 𝒷 +\DeclareUnicodeCharacter{1D4B8}{\ensuremath{\mathcal{c}}}% 𝒸 +\DeclareUnicodeCharacter{1D4B9}{\ensuremath{\mathcal{d}}}% 𝒹 +\DeclareUnicodeCharacter{212F}{\ensuremath{\mathcal{e}}}% ℯ +\DeclareUnicodeCharacter{1D4BB}{\ensuremath{\mathcal{f}}}% 𝒻 +\DeclareUnicodeCharacter{210A}{\ensuremath{\mathcal{g}}}% ℊ +\DeclareUnicodeCharacter{1D4BD}{\ensuremath{\mathcal{h}}}% 𝒽 +\DeclareUnicodeCharacter{1D4BE}{\ensuremath{\mathcal{i}}}% 𝒾 +\DeclareUnicodeCharacter{1D4BF}{\ensuremath{\mathcal{j}}}% 𝒿 +\DeclareUnicodeCharacter{1D4C0}{\ensuremath{\mathcal{k}}}% 𝓀 +\DeclareUnicodeCharacter{1D4C1}{\ensuremath{\mathcal{l}}}% 𝓁 +\DeclareUnicodeCharacter{1D4C2}{\ensuremath{\mathcal{m}}}% 𝓂 +\DeclareUnicodeCharacter{1D4C3}{\ensuremath{\mathcal{n}}}% 𝓃 +\DeclareUnicodeCharacter{2134}{\ensuremath{\mathcal{o}}}% ℴ +\DeclareUnicodeCharacter{1D4C5}{\ensuremath{\mathcal{p}}}% 𝓅 +\DeclareUnicodeCharacter{1D4C6}{\ensuremath{\mathcal{q}}}% 𝓆 +\DeclareUnicodeCharacter{1D4C7}{\ensuremath{\mathcal{r}}}% 𝓇 +\DeclareUnicodeCharacter{1D4C8}{\ensuremath{\mathcal{s}}}% 𝓈 +\DeclareUnicodeCharacter{1D4C9}{\ensuremath{\mathcal{t}}}% 𝓉 +\DeclareUnicodeCharacter{1D4CA}{\ensuremath{\mathcal{u}}}% 𝓊 +\DeclareUnicodeCharacter{1D4CB}{\ensuremath{\mathcal{v}}}% 𝓋 +\DeclareUnicodeCharacter{1D4CC}{\ensuremath{\mathcal{w}}}% 𝓌 +\DeclareUnicodeCharacter{1D4CD}{\ensuremath{\mathcal{x}}}% 𝓍 +\DeclareUnicodeCharacter{1D4CE}{\ensuremath{\mathcal{y}}}% 𝓎 +\DeclareUnicodeCharacter{1D4CF}{\ensuremath{\mathcal{z}}}% 𝓏 +\makeatother +}>>>|) \ No newline at end of file diff --git a/with-manual.rkt b/with-manual.rkt new file mode 100644 index 00000000..105309d1 --- /dev/null +++ b/with-manual.rkt @@ -0,0 +1,8 @@ +#lang racket/base + +(require racket/require + (subtract-in scribble/manual scribble-enhanced) + scribble-enhanced) + +(provide (all-from-out scribble/manual + scribble-enhanced))