bkyk8rc3zvpnsf5inmcqq4n3k98cv6hj-my-site-hyper-literate-git.test.suzanne.soy-0.0.1

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit e6d386262744c2cfe0c5b72c9682dc7e121e8a15
parent f2c9297253c11cfb8fb406178850ec5e468eb2db
Author: Matthew Flatt <mflatt@racket-lang.org>
Date:   Sun, 25 Nov 2012 06:22:21 -0700

scribble latex: work around `\href{...#...}{...}' as a macro argument

The `math' document build was failing because `\marginpar' does not
like `\href{...#...}{...}' as an argument.

original commit: 24f358a5d7afca40fcf734af94c2c94a80a817dc

Diffstat:
Mcollects/scribble/latex-render.rkt | 19+++++++++++++------
Mcollects/scribble/scribble.tex | 4++++
2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/collects/scribble/latex-render.rkt b/collects/scribble/latex-render.rkt @@ -391,12 +391,19 @@ (let ([v (car l)]) (cond [(target-url? v) - (printf "\\href{~a}{" (regexp-replace* #rx"%" - (let ([p (target-url-addr v)]) - (if (path? p) - (path->string p) - p)) - "\\\\%")) + (define target (regexp-replace* #rx"%" + (let ([p (target-url-addr v)]) + (if (path? p) + (path->string p) + p)) + "\\\\%")) + (if (regexp-match? #rx"^[^#]*#[^#]*$" target) + ;; work around a problem with `\href' as an + ;; argument to other macros, such as `\marginpar': + (let ([l (string-split target "#")]) + (printf "\\Shref{~a}{~a}{" (car l) (cadr l))) + ;; normal: + (printf "\\href{~a}{" target)) (loop (cdr l) #t) (printf "}")] [(color-property? v) diff --git a/collects/scribble/scribble.tex b/collects/scribble/scribble.tex @@ -190,6 +190,10 @@ % Helper for box-mode macros: \newcommand{\Svcenter}[1]{$\vcenter{#1}$} +% Helper to work around a problem with "#"s for URLs within \href +% within other macros: +\newcommand{\Shref}[3]{\href{#1\##2}{#3}} + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Scribble then generates the following: