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
This commit is contained in:
Matthew Flatt 2012-11-25 06:22:21 -07:00
parent f2c9297253
commit e6d3862627
2 changed files with 17 additions and 6 deletions

View File

@ -391,12 +391,19 @@
(let ([v (car l)])
(cond
[(target-url? v)
(printf "\\href{~a}{" (regexp-replace* #rx"%"
(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)

View File

@ -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: