Allow for manipulating scribble.tex imports
This commit is contained in:
parent
1db48e6fc6
commit
2881ef290d
|
@ -1697,6 +1697,15 @@ rendering.
|
||||||
|
|
||||||
See also @racketmodname[scribble/latex-prefix].}
|
See also @racketmodname[scribble/latex-prefix].}
|
||||||
|
|
||||||
|
@defstruct[(latex-defaults+replacements latex-defaults)
|
||||||
|
([replacements (hash/c string? (or/c bytes? path-string?
|
||||||
|
(cons/c 'collects (listof bytes?))))])]{
|
||||||
|
Like @racket[latex-defaults] but it allows for more configuration. For example if
|
||||||
|
the @racket[replacements] maps @racket["scribble-load-replace.tex"] to @racket["my-scribble.tex"],
|
||||||
|
then the @racket["my-scribble.tex"] file in the current directory will we used in place
|
||||||
|
of the standard scribble package inclusion header.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@defstruct[command-extras ([arguments (listof string?)])]{
|
@defstruct[command-extras ([arguments (listof string?)])]{
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#lang scheme/base
|
#lang scheme/base
|
||||||
(require "private/provide-structs.rkt"
|
(require "private/provide-structs.rkt"
|
||||||
|
racket/serialize
|
||||||
racket/contract/base)
|
racket/contract/base)
|
||||||
|
|
||||||
(provide-structs
|
(provide-structs
|
||||||
|
@ -7,4 +8,6 @@
|
||||||
[latex-defaults ([prefix (or/c bytes? path-string? (cons/c 'collects (listof bytes?)))]
|
[latex-defaults ([prefix (or/c bytes? path-string? (cons/c 'collects (listof bytes?)))]
|
||||||
[style (or/c bytes? path-string? (cons/c 'collects (listof bytes?)))]
|
[style (or/c bytes? path-string? (cons/c 'collects (listof bytes?)))]
|
||||||
[extra-files (listof (or/c path-string? (cons/c 'collects (listof bytes?))))])]
|
[extra-files (listof (or/c path-string? (cons/c 'collects (listof bytes?))))])]
|
||||||
|
[(latex-defaults+replacements latex-defaults)
|
||||||
|
([replacements (hash/c string? (or/c bytes? path-string? (cons/c 'collects (listof bytes?))))])]
|
||||||
[command-extras ([arguments (listof string?)])])
|
[command-extras ([arguments (listof string?)])])
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
racket/runtime-path
|
racket/runtime-path
|
||||||
racket/port
|
racket/port
|
||||||
racket/string
|
racket/string
|
||||||
|
racket/path
|
||||||
racket/list
|
racket/list
|
||||||
setup/collects
|
setup/collects
|
||||||
file/convertible)
|
file/convertible)
|
||||||
|
@ -23,8 +24,11 @@
|
||||||
(define-struct (toc-paragraph paragraph) ())
|
(define-struct (toc-paragraph paragraph) ())
|
||||||
|
|
||||||
(define-runtime-path scribble-prefix-tex "scribble-prefix.tex")
|
(define-runtime-path scribble-prefix-tex "scribble-prefix.tex")
|
||||||
|
(define-runtime-path scribble-packages-tex "scribble-packages.tex")
|
||||||
|
(define-runtime-path scribble-load-tex "scribble-load.tex")
|
||||||
(define-runtime-path scribble-tex "scribble.tex")
|
(define-runtime-path scribble-tex "scribble.tex")
|
||||||
(define-runtime-path scribble-style-tex "scribble-style.tex")
|
(define-runtime-path scribble-style-tex "scribble-style.tex")
|
||||||
|
(define-runtime-path scribble-load-replace-tex "scribble-load-replace.tex")
|
||||||
|
|
||||||
(define (color->string c)
|
(define (color->string c)
|
||||||
(if (string? c)
|
(if (string? c)
|
||||||
|
@ -82,6 +86,17 @@
|
||||||
(define/public (render-part-depth) #f)
|
(define/public (render-part-depth) #f)
|
||||||
|
|
||||||
(define/override (render-one d ri fn)
|
(define/override (render-one d ri fn)
|
||||||
|
(define (maybe-replace file defaults)
|
||||||
|
(cond [(and defaults
|
||||||
|
(latex-defaults+replacements? defaults)
|
||||||
|
(hash-ref (latex-defaults+replacements-replacements defaults)
|
||||||
|
(path->string (file-name-from-path file))
|
||||||
|
#f)) =>
|
||||||
|
(lambda (v)
|
||||||
|
(cond
|
||||||
|
[(bytes? v) v]
|
||||||
|
[else (collects-relative->path v)]))]
|
||||||
|
[else file]))
|
||||||
(let* ([defaults (ormap (lambda (v) (and (latex-defaults? v) v))
|
(let* ([defaults (ormap (lambda (v) (and (latex-defaults? v) v))
|
||||||
(style-properties (part-style d)))]
|
(style-properties (part-style d)))]
|
||||||
[prefix-file (or prefix-file
|
[prefix-file (or prefix-file
|
||||||
|
@ -98,15 +113,17 @@
|
||||||
[(bytes? v) v]
|
[(bytes? v) v]
|
||||||
[else (collects-relative->path v)])))
|
[else (collects-relative->path v)])))
|
||||||
scribble-style-tex)]
|
scribble-style-tex)]
|
||||||
[all-style-files (cons scribble-tex
|
[all-style-files (list* scribble-load-tex
|
||||||
(append (extract-part-style-files
|
(maybe-replace scribble-load-replace-tex defaults)
|
||||||
d
|
scribble-tex
|
||||||
ri
|
(append (extract-part-style-files
|
||||||
(lambda (p) #f)
|
d
|
||||||
tex-addition?
|
ri
|
||||||
tex-addition-path)
|
(lambda (p) #f)
|
||||||
(list style-file)
|
tex-addition?
|
||||||
style-extra-files))]
|
tex-addition-path)
|
||||||
|
(list style-file)
|
||||||
|
style-extra-files))]
|
||||||
[whole-doc? (not (render-part-depth))])
|
[whole-doc? (not (render-part-depth))])
|
||||||
(if whole-doc?
|
(if whole-doc?
|
||||||
(for ([style-file (in-list (cons prefix-file all-style-files))])
|
(for ([style-file (in-list (cons prefix-file all-style-files))])
|
||||||
|
|
1
scribble-lib/scribble/scribble-load-replace.tex
Normal file
1
scribble-lib/scribble/scribble-load-replace.tex
Normal file
|
@ -0,0 +1 @@
|
||||||
|
% this bit intentionally left blank
|
18
scribble-lib/scribble/scribble-load.tex
Normal file
18
scribble-lib/scribble/scribble-load.tex
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
|
||||||
|
\newcommand{\packageGraphicx}{\usepackage{graphicx}}
|
||||||
|
\newcommand{\packageHyperref}{\usepackage{hyperref}}
|
||||||
|
\newcommand{\renewrmdefault}{\renewcommand{\rmdefault}{ptm}}
|
||||||
|
\newcommand{\packageRelsize}{\usepackage{relsize}}
|
||||||
|
\newcommand{\packageMathabx}{\usepackage{mathabx}}
|
||||||
|
% Avoid conflicts between "mathabx" and "wasysym":
|
||||||
|
\newcommand{\packageWasysym}{
|
||||||
|
\let\leftmoon\relax \let\rightmoon\relax \let\fullmoon\relax \let\newmoon\relax \let\diameter\relax
|
||||||
|
\usepackage{wasysym}}
|
||||||
|
\newcommand{\packageTextcomp}{\usepackage{textcomp}}
|
||||||
|
\newcommand{\packageFramed}{\usepackage{framed}}
|
||||||
|
\newcommand{\packageHyphenat}{\usepackage[htt]{hyphenat}}
|
||||||
|
\newcommand{\packageColor}{\usepackage[usenames,dvipsnames]{color}}
|
||||||
|
\newcommand{\doHypersetup}{\hypersetup{bookmarks=true,bookmarksopen=true,bookmarksnumbered=true}}
|
||||||
|
\newcommand{\packageTocstyle}{\IfFileExists{tocstyle.sty}{\usepackage{tocstyle}\usetocstyle{standard}}{}}
|
||||||
|
\newcommand{\packageCJK}{\IfFileExists{CJK.sty}{\usepackage{CJK}}{}}
|
||||||
|
|
|
@ -1,20 +1,18 @@
|
||||||
% This is the default style configuration for Scribble-generated Latex
|
% This is the default style configuration for Scribble-generated Latex
|
||||||
|
|
||||||
\usepackage{graphicx}
|
\packageGraphicx
|
||||||
\usepackage{hyperref}
|
\packageHyperref
|
||||||
\renewcommand{\rmdefault}{ptm}
|
\renewrmdefault
|
||||||
\usepackage{relsize}
|
\packageRelsize
|
||||||
\usepackage{mathabx}
|
\packageMathabx
|
||||||
% Avoid conflicts between "mathabx" and "wasysym":
|
\packageWasysym
|
||||||
\let\leftmoon\relax \let\rightmoon\relax \let\fullmoon\relax \let\newmoon\relax \let\diameter\relax
|
\packageTextcomp
|
||||||
\usepackage{wasysym}
|
\packageFramed
|
||||||
\usepackage{textcomp}
|
\packageHyphenat
|
||||||
\usepackage{framed}
|
\packageColor
|
||||||
\usepackage[htt]{hyphenat}
|
\doHypersetup
|
||||||
\usepackage[usenames,dvipsnames]{color}
|
\packageTocstyle
|
||||||
\hypersetup{bookmarks=true,bookmarksopen=true,bookmarksnumbered=true}
|
\packageCJK
|
||||||
\IfFileExists{tocstyle.sty}{\usepackage{tocstyle}\usetocstyle{standard}}{}
|
|
||||||
\IfFileExists{CJK.sty}{\usepackage{CJK}}{}
|
|
||||||
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
% Configuration that is especially meant to be overridden:
|
% Configuration that is especially meant to be overridden:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user