fix some scribble->latex problems
svn: r9106 original commit: 741d856187b2477bde931a65a41dae1b4ab65c32
This commit is contained in:
parent
f2846675f2
commit
7f9b383b0f
|
@ -21,6 +21,9 @@
|
||||||
|
|
||||||
(define/public (get-suffix) #".txt")
|
(define/public (get-suffix) #".txt")
|
||||||
|
|
||||||
|
(define/public (index-manual-newlines?)
|
||||||
|
#f)
|
||||||
|
|
||||||
(define/public (format-number number sep)
|
(define/public (format-number number sep)
|
||||||
(if (or (null? number)
|
(if (or (null? number)
|
||||||
(andmap not number))
|
(andmap not number))
|
||||||
|
|
|
@ -221,10 +221,12 @@
|
||||||
(make-table 'index (map (lambda (row)
|
(make-table 'index (map (lambda (row)
|
||||||
(list (make-flow (list (make-paragraph row)))))
|
(list (make-flow (list (make-paragraph row)))))
|
||||||
rows)))
|
rows)))
|
||||||
(define line-break (make-element 'newline '("\n")))
|
|
||||||
(define contents
|
(define contents
|
||||||
(lambda (renderer sec ri)
|
(lambda (renderer sec ri)
|
||||||
(define l null)
|
(define l null)
|
||||||
|
(define line-break (if (send renderer index-manual-newlines?)
|
||||||
|
(make-element 'newline '("\n"))
|
||||||
|
""))
|
||||||
(define alpha-starts (make-hash-table))
|
(define alpha-starts (make-hash-table))
|
||||||
(hash-table-for-each
|
(hash-table-for-each
|
||||||
(let ([parent (collected-info-parent (part-collected-info sec ri))])
|
(let ([parent (collected-info-parent (part-collected-info sec ri))])
|
||||||
|
@ -235,7 +237,8 @@
|
||||||
(when (and (pair? k) (eq? 'index-entry (car k)))
|
(when (and (pair? k) (eq? 'index-entry (car k)))
|
||||||
(set! l (cons (cons (cadr k) v) l)))))
|
(set! l (cons (cons (cadr k) v) l)))))
|
||||||
(set! l (sort l cadr-string-lists<?))
|
(set! l (sort l cadr-string-lists<?))
|
||||||
(rows
|
(apply
|
||||||
|
rows
|
||||||
(let loop ([i l] [alpha alpha])
|
(let loop ([i l] [alpha alpha])
|
||||||
(define (add-letter let l)
|
(define (add-letter let l)
|
||||||
(list* (make-element "nonavigation" (list (string let))) " " l))
|
(list* (make-element "nonavigation" (list (string let))) " " l))
|
||||||
|
@ -258,18 +261,22 @@
|
||||||
(loop (cdr i) (cdr alpha)))]
|
(loop (cdr i) (cdr alpha)))]
|
||||||
[else (loop (cdr i) alpha)]))]))
|
[else (loop (cdr i) alpha)]))]))
|
||||||
(list 'nbsp)
|
(list 'nbsp)
|
||||||
(map (lambda (i)
|
((if (send renderer index-manual-newlines?)
|
||||||
(define e
|
list
|
||||||
(make-link-element "indexlink"
|
(lambda (v)
|
||||||
`(,@(commas (caddr i)) ,line-break)
|
(map list v)))
|
||||||
(car i)))
|
(map (lambda (i)
|
||||||
(cond [(hash-table-get alpha-starts i #f)
|
(define e
|
||||||
=> (lambda (let)
|
(make-link-element "indexlink"
|
||||||
(make-element (make-url-anchor
|
`(,@(commas (caddr i)) ,line-break)
|
||||||
(format "alpha:~a" (char-upcase let)))
|
(car i)))
|
||||||
(list e)))]
|
(cond [(hash-table-get alpha-starts i #f)
|
||||||
[else e]))
|
=> (lambda (let)
|
||||||
l))))
|
(make-element (make-url-anchor
|
||||||
|
(format "alpha:~a" (char-upcase let)))
|
||||||
|
(list e)))]
|
||||||
|
[else e]))
|
||||||
|
l)))))
|
||||||
(list (make-delayed-flow-element contents)))
|
(list (make-delayed-flow-element contents)))
|
||||||
|
|
||||||
;; ----------------------------------------
|
;; ----------------------------------------
|
||||||
|
|
|
@ -193,6 +193,9 @@
|
||||||
|
|
||||||
(define/override (get-suffix) #".html")
|
(define/override (get-suffix) #".html")
|
||||||
|
|
||||||
|
(define/override (index-manual-newlines?)
|
||||||
|
#t)
|
||||||
|
|
||||||
;; ----------------------------------------
|
;; ----------------------------------------
|
||||||
|
|
||||||
(define/override (start-collect ds fns ci)
|
(define/override (start-collect ds fns ci)
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
|
|
||||||
(module latex-render scheme/base
|
(module latex-render scheme/base
|
||||||
(require "struct.ss"
|
(require "struct.ss"
|
||||||
mzlib/class)
|
mzlib/class
|
||||||
|
scheme/runtime-path
|
||||||
|
scheme/port
|
||||||
|
(for-syntax scheme/base))
|
||||||
(provide render-mixin)
|
(provide render-mixin)
|
||||||
|
|
||||||
(define current-table-mode (make-parameter #f))
|
(define current-table-mode (make-parameter #f))
|
||||||
|
@ -10,6 +13,8 @@
|
||||||
|
|
||||||
(define-struct (toc-paragraph paragraph) ())
|
(define-struct (toc-paragraph paragraph) ())
|
||||||
|
|
||||||
|
(define-runtime-path scribble-tex "scribble.tex")
|
||||||
|
|
||||||
(define (render-mixin %)
|
(define (render-mixin %)
|
||||||
(class %
|
(class %
|
||||||
(define/override (get-suffix) #".tex")
|
(define/override (get-suffix) #".tex")
|
||||||
|
@ -20,75 +25,21 @@
|
||||||
install-file
|
install-file
|
||||||
format-number)
|
format-number)
|
||||||
|
|
||||||
(define (define-color s s2)
|
|
||||||
(printf "\\newcommand{\\~a}[1]{{\\mytexttt{\\color{~a}{#1}}}}\n" s s2))
|
|
||||||
|
|
||||||
(define/override (render-one d ri fn)
|
(define/override (render-one d ri fn)
|
||||||
(printf "\\documentclass{article}\n")
|
(with-input-from-file scribble-tex
|
||||||
(printf "\\parskip=10pt%\n")
|
(lambda ()
|
||||||
(printf "\\parindent=0pt%\n")
|
(copy-port (current-input-port)
|
||||||
(printf "\\usepackage{graphicx}\n")
|
(current-output-port))))
|
||||||
(printf "\\usepackage{hyperref}\n")
|
(printf "\\begin{document}\n\\preDoc\n")
|
||||||
(printf "\\renewcommand{\\rmdefault}{ptm}\n")
|
|
||||||
;; (printf "\\usepackage{fullpage}\n")
|
|
||||||
(printf "\\usepackage{longtable}\n")
|
|
||||||
(printf "\\usepackage[usenames,dvipsnames]{color}\n")
|
|
||||||
(printf "\\hypersetup{bookmarks=true,bookmarksopen=true,bookmarksnumbered=true}\n")
|
|
||||||
(printf "\\newcommand{\\mytexttt}[1]{{\\small \\texttt{#1}}}\n")
|
|
||||||
(define-color "schemeplain" "black")
|
|
||||||
(printf "\\newcommand{\\schemekeyword}[1]{{\\color{black}{\\mytexttt{\\textbf{#1}}}}}\n")
|
|
||||||
(printf "\\newcommand{\\schemesyntaxlink}[1]{\\schemekeyword{#1}}\n")
|
|
||||||
(printf "\\definecolor{CommentColor}{rgb}{0.76,0.45,0.12}\n")
|
|
||||||
(printf "\\definecolor{ParenColor}{rgb}{0.52,0.24,0.14}\n")
|
|
||||||
(printf "\\definecolor{IdentifierColor}{rgb}{0.15,0.15,0.50}\n")
|
|
||||||
(printf "\\definecolor{ResultColor}{rgb}{0.0,0.0,0.69}\n")
|
|
||||||
(printf "\\definecolor{ValueColor}{rgb}{0.13,0.55,0.13}\n")
|
|
||||||
(printf "\\definecolor{OutputColor}{rgb}{0.59,0.00,0.59}\n")
|
|
||||||
(define-color "schemecomment" "CommentColor")
|
|
||||||
(define-color "schemeparen" "ParenColor")
|
|
||||||
(define-color "schemeinputbg" "ParenColor")
|
|
||||||
(define-color "schemesymbol" "IdentifierColor")
|
|
||||||
(define-color "schemevalue" "ValueColor")
|
|
||||||
(define-color "schemevaluelink" "blue")
|
|
||||||
(define-color "schememodlink" "blue")
|
|
||||||
(define-color "schemeresult" "ResultColor")
|
|
||||||
(define-color "schemestdout" "OutputColor")
|
|
||||||
(define-color "schememeta" "IdentifierColor")
|
|
||||||
(define-color "schememod" "black")
|
|
||||||
(define-color "schemereader" "black")
|
|
||||||
(define-color "schemevariablecol" "IdentifierColor")
|
|
||||||
(printf "\\newcommand{\\schemevariable}[1]{{\\schemevariablecol{\\textsl{#1}}}}\n")
|
|
||||||
(define-color "schemeerrorcol" "red")
|
|
||||||
(printf "\\newcommand{\\schemeerror}[1]{{\\schemeerrorcol{\\textrm{\\textit{#1}}}}}\n")
|
|
||||||
(printf "\\newcommand{\\schemeopt}[1]{#1}\n")
|
|
||||||
(printf "\\newcommand{\\textsub}[1]{$_{#1}$}\n")
|
|
||||||
(printf "\\newcommand{\\textsuper}[1]{$^{#1}$}\n")
|
|
||||||
(printf "\\newcommand{\\refcolumn}[1]{#1}\n")
|
|
||||||
(printf "\\newcommand{\\refcontent}[1]{#1}\n")
|
|
||||||
(printf "\\newcommand{\\smaller}[1]{{\\footnotesize #1}}\n")
|
|
||||||
(printf "\\definecolor{PaleBlue}{rgb}{0.90,0.90,1.0}\n")
|
|
||||||
(printf "\\definecolor{LightGray}{rgb}{0.90,0.90,0.90}\n")
|
|
||||||
(printf "\\newcommand{\\intextcolor}[2]{\\textcolor{#1}{#2}}\n")
|
|
||||||
(printf "\\newcommand{\\intextrgbcolor}[2]{\\textcolor[rgb]{#1}{#2}}\n")
|
|
||||||
(printf "\\newcommand{\\incolorbox}[2]{{\\fboxrule=0pt\\fboxsep=0pt\\colorbox{#1}{#2}}}\n")
|
|
||||||
(printf "\\newcommand{\\inrgbcolorbox}[2]{{\\fboxrule=0pt\\fboxsep=0pt\\colorbox[rgb]{#1}{#2}}}\n")
|
|
||||||
(printf "\\newcommand{\\schemeinput}[1]{\\incolorbox{LightGray}{\\schemeinputbg{#1}}}\n")
|
|
||||||
(printf "\\newcommand{\\highlighted}[1]{\\colorbox{PaleBlue}{\\hspace{-0.5ex}\\schemeinputbg{#1}\\hspace{-0.5ex}}}\n")
|
|
||||||
(printf "\\newcommand{\\plainlink}[1]{#1}\n")
|
|
||||||
(printf "\\newcommand{\\techlink}[1]{#1}\n")
|
|
||||||
(printf "\\newcommand{\\badlink}[1]{#1}\n")
|
|
||||||
(printf "\\newcommand{\\indexlink}[1]{#1}\n")
|
|
||||||
(printf "\\newcommand{\\imageleft}[1]{} % drop it\n")
|
|
||||||
(printf "\\begin{document}\n\\sloppy\n")
|
|
||||||
(when (part-title-content d)
|
(when (part-title-content d)
|
||||||
(printf "\\title{")
|
(printf "\\titleAndVersion{")
|
||||||
(render-content (part-title-content d) d ri)
|
(render-content (part-title-content d) d ri)
|
||||||
(printf "\\\\{\\normalsize Version ~a}}\\maketitle\n"
|
(printf "}{~a}\n"
|
||||||
(or (and (versioned-part? d)
|
(or (and (versioned-part? d)
|
||||||
(versioned-part-version d))
|
(versioned-part-version d))
|
||||||
(version))))
|
(version))))
|
||||||
(render-part d ri)
|
(render-part d ri)
|
||||||
(printf "\\end{document}\n"))
|
(printf "\\postDoc\n\\end{document}\n"))
|
||||||
|
|
||||||
(define/override (render-part d ri)
|
(define/override (render-part d ri)
|
||||||
(let ([number (collected-info-number (part-collected-info d ri))])
|
(let ([number (collected-info-number (part-collected-info d ri))])
|
||||||
|
|
82
collects/scribble/scribble.tex
Normal file
82
collects/scribble/scribble.tex
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
% This is the default prefix for Scribble-generated HTML
|
||||||
|
|
||||||
|
\documentclass{article}
|
||||||
|
|
||||||
|
\parskip=10pt
|
||||||
|
\parindent=0pt
|
||||||
|
|
||||||
|
% Adjust margins to match HTML width for
|
||||||
|
% fixed-width font
|
||||||
|
\advance \oddsidemargin by -0.15in
|
||||||
|
\advance \evensidemargin by -0.15in
|
||||||
|
\advance \textwidth by 0.3in
|
||||||
|
|
||||||
|
\usepackage{graphicx}
|
||||||
|
\usepackage{hyperref}
|
||||||
|
\renewcommand{\rmdefault}{ptm}
|
||||||
|
\usepackage{longtable}
|
||||||
|
\usepackage[htt]{hyphenat}
|
||||||
|
\usepackage[usenames,dvipsnames]{color}
|
||||||
|
\hypersetup{bookmarks=true,bookmarksopen=true,bookmarksnumbered=true}
|
||||||
|
|
||||||
|
\newcommand{\inColor}[2]{{\mytexttt{\color{#1}{#2}}}}
|
||||||
|
\definecolor{CommentColor}{rgb}{0.76,0.45,0.12}
|
||||||
|
\definecolor{ParenColor}{rgb}{0.52,0.24,0.14}
|
||||||
|
\definecolor{IdentifierColor}{rgb}{0.15,0.15,0.50}
|
||||||
|
\definecolor{ResultColor}{rgb}{0.0,0.0,0.69}
|
||||||
|
\definecolor{ValueColor}{rgb}{0.13,0.55,0.13}
|
||||||
|
\definecolor{OutputColor}{rgb}{0.59,0.00,0.59}
|
||||||
|
\definecolor{PaleBlue}{rgb}{0.90,0.90,1.0}
|
||||||
|
\definecolor{LightGray}{rgb}{0.90,0.90,0.90}
|
||||||
|
|
||||||
|
\newcommand{\mytexttt}[1]{{\texttt{#1}}}
|
||||||
|
\newcommand{\schemeplain}[1]{\inColor{black}{#1}}
|
||||||
|
\newcommand{\schemekeyword}[1]{{\color{black}{\mytexttt{\textbf{#1}}}}}
|
||||||
|
\newcommand{\schemesyntaxlink}[1]{\schemekeyword{#1}}
|
||||||
|
\newcommand{\schemecomment}[1]{\inColor{CommentColor}{#1}}
|
||||||
|
\newcommand{\schemeparen}[1]{\inColor{ParenColor}{#1}}
|
||||||
|
\newcommand{\schemeinputbg}[1]{\inColor{ParenColor}{#1}}
|
||||||
|
\newcommand{\schemesymbol}[1]{\inColor{IdentifierColor}{#1}}
|
||||||
|
\newcommand{\schemevalue}[1]{\inColor{ValueColor}{#1}}
|
||||||
|
\newcommand{\schemevaluelink}[1]{\inColor{blue}{#1}}
|
||||||
|
\newcommand{\schememodlink}[1]{\inColor{blue}{#1}}
|
||||||
|
\newcommand{\schemeresult}[1]{\inColor{ResultColor}{#1}}
|
||||||
|
\newcommand{\schemestdout}[1]{\inColor{OutputColor}{#1}}
|
||||||
|
\newcommand{\schememeta}[1]{\inColor{IdentifierColor}{#1}}
|
||||||
|
\newcommand{\schememod}[1]{\inColor{black}{#1}}
|
||||||
|
\newcommand{\schemereader}[1]{\inColor{black}{#1}}
|
||||||
|
\newcommand{\schemevariablecol}[1]{\inColor{IdentifierColor}{#1}}
|
||||||
|
\newcommand{\schemevariable}[1]{{\schemevariablecol{\textsl{#1}}}}
|
||||||
|
\newcommand{\schemeerrorcol}[1]{\inColor{red}{#1}}
|
||||||
|
\newcommand{\schemeerror}[1]{{\schemeerrorcol{\textrm{\textit{#1}}}}}
|
||||||
|
\newcommand{\schemeopt}[1]{#1}
|
||||||
|
\newcommand{\textsub}[1]{$_{#1}$}
|
||||||
|
\newcommand{\textsuper}[1]{$^{#1}$}
|
||||||
|
\newcommand{\refcolumn}[1]{#1}
|
||||||
|
\newcommand{\refcontent}[1]{#1}
|
||||||
|
\newcommand{\intextcolor}[2]{\textcolor{#1}{#2}}
|
||||||
|
\newcommand{\intextrgbcolor}[2]{\textcolor[rgb]{#1}{#2}}
|
||||||
|
\newcommand{\incolorbox}[2]{{\fboxrule=0pt\fboxsep=0pt\colorbox{#1}{#2}}}
|
||||||
|
\newcommand{\inrgbcolorbox}[2]{{\fboxrule=0pt\fboxsep=0pt\colorbox[rgb]{#1}{#2}}}
|
||||||
|
\newcommand{\schemeinput}[1]{\incolorbox{LightGray}{\schemeinputbg{#1}}}
|
||||||
|
\newcommand{\highlighted}[1]{\colorbox{PaleBlue}{\hspace{-0.5ex}\schemeinputbg{#1}\hspace{-0.5ex}}}
|
||||||
|
\newcommand{\plainlink}[1]{#1}
|
||||||
|
\newcommand{\techlink}[1]{#1}
|
||||||
|
\newcommand{\badlink}[1]{#1}
|
||||||
|
\newcommand{\indexlink}[1]{#1}
|
||||||
|
\newcommand{\imageleft}[1]{} % drop it
|
||||||
|
\newcommand{\smaller}[1]{{\footnotesize #1}}
|
||||||
|
|
||||||
|
\newcommand{\titleAndVersion}[2]{\title{#1\\{\normalsize Version #2}}\maketitle}
|
||||||
|
|
||||||
|
\newcommand{\preDoc}{\sloppy}
|
||||||
|
\newcommand{\postDoc}{}
|
||||||
|
|
||||||
|
% Scribble then generates the following:
|
||||||
|
%
|
||||||
|
% \begin{document}
|
||||||
|
% \preDoc
|
||||||
|
% \titleAndVersion{...}{...}
|
||||||
|
% ... document content ...
|
||||||
|
% \postDoc
|
||||||
|
% \end{document}
|
Loading…
Reference in New Issue
Block a user