Scribble: add #:left?' optional argument to margin-note'

original commit: ec2a9177492705c66d39c2e48d909ba3bd2115b6
This commit is contained in:
Matthew Flatt 2011-03-01 14:35:50 -07:00
parent abc3822ad4
commit f96e6f14e0
5 changed files with 49 additions and 15 deletions

View File

@ -510,8 +510,8 @@
#:rest (listof pre-content?)
element?)]
[url (-> string? element?)]
[margin-note (->* () () #:rest (listof pre-flow?) block?)]
[margin-note* (->* () () #:rest (listof pre-content?) element?)]
[margin-note (->* () (#:left? any/c) #:rest (listof pre-flow?) block?)]
[margin-note* (->* () (#:left? any/c) #:rest (listof pre-content?) element?)]
[centered (->* () () #:rest (listof pre-flow?) block?)]
[verbatim (->* (string?) (#:indent exact-nonnegative-integer?) #:rest (listof string?) block?)])
@ -534,22 +534,24 @@
(define (url str)
(hyperlink str (make-element 'url str)))
(define (margin-note . c)
(define (margin-note #:left? [left? #f] . c)
(make-nested-flow
(make-style "refpara" '(command never-indents))
(make-style (if left? "refparaleft" "refpara")
'(command never-indents))
(list
(make-nested-flow
(make-style "refcolumn" null)
(make-style (if left? "refcolumnleft" "refcolumn")
null)
(list
(make-nested-flow
(make-style "refcontent" null)
(decode-flow c)))))))
(define (margin-note* . c)
(define (margin-note* #:left? [left? #f] . c)
(make-element
(make-style "refelem" null)
(make-style (if left? "refelemleft" "refelem") null)
(make-element
(make-style "refcolumn" null)
(make-style (if left? "refcolumnleft" "refcolumn") null)
(make-element
(make-style "refcontent" null)
(decode-content c)))))

View File

@ -313,7 +313,7 @@
(let ([v (car l)])
(cond
[(target-url? v)
(printf "\\href{~a}{" (target-url-addr v))
(printf "\\href{~a}{" (regexp-replace* #rx"%" (target-url-addr v) "\\\\%"))
(loop (cdr l) #t)
(printf "}")]
[(color-property? v)

View File

@ -8,7 +8,7 @@
see if any font is set. */
/* Monospace: */
.maincolumn, .refpara, .tocset, .stt, .hspace {
.maincolumn, .refpara, .refelem, .tocset, .stt, .hspace, .refparaleft, .refelemleft {
font-family: monospace;
}
@ -161,7 +161,7 @@ table td {
margin: 0em -13em 0em 0em;
}
.refpara {
.refpara, .refparaleft {
top: -1em;
}
@ -184,6 +184,26 @@ table td {
margin-bottom: 0;
}
.refparaleft {
position: relative;
float: left;
right: 2em;
height: 0em;
width: 13em;
margin: 0em 0em 0em -13em;
}
.refcolumnleft, .refelemleft {
background-color: #F5F5DC;
display: block;
position: relative;
width: 13em;
font-size: 85%;
border: 0.5em solid #F5F5DC;
margin: 0 0 0 0;
}
/* ---------------------------------------- */
/* Table of contents, inline */

View File

@ -104,11 +104,15 @@
% The \refpara command corresponds to `margin-note'. The
% refcolumn and refcontent environments also wrap the note,
% because they simplify the CSS side.
\newcommand{\refpara}[1]{\marginpar{\raggedright \footnotesize #1}}
\newcommand{\refpara}[1]{\normalmarginpar\marginpar{\raggedright \footnotesize #1}}
\newcommand{\refelem}[1]{\refpara{#1}}
\newenvironment{refcolumn}{}{}
\newenvironment{refcontent}{}{}
\newcommand{\refparaleft}[1]{\reversemarginpar\marginpar{\raggedright \footnotesize #1}}
\newcommand{\refelemleft}[1]{\refparaleft{#1}}
\newenvironment{refcolumnleft}{\begin{refcolumn}}{\end{refcolumn}}
% Macros used by `title' and `author':
\newcommand{\titleAndVersionAndAuthors}[3]{\title{#1\\{\normalsize Version #2}}\author{#3}\maketitle}
\newcommand{\titleAndVersionAndEmptyAuthors}[3]{\title{#1\\{\normalsize Version #2}}#3\maketitle}

View File

@ -168,13 +168,21 @@ address-harvesting robots.}
Produces a @tech{nested flow} whose content is centered.}
@defproc[(margin-note [pre-flow pre-flow?] ...) block?]{
@defproc[(margin-note [pre-flow pre-flow?] ...
[#:left? left? any/c #f])
block?]{
Produces a @tech{nested flow} that is typeset in the margin, instead
of inlined.}
of inlined.
If @racket[left?] is true, then the note is shown on the opposite as
it would normally be shown (which is the left-hand side for HTML
output). Beware of colliding with output for a table of contents.}
@defproc[(margin-note* [pre-content pre-content?] ...) element?]{
@defproc[(margin-note* [pre-content pre-content?] ...
[#:left? left? any/c #f])
element?]{
Produces an @racket[element] that is typeset in the margin, instead of
inlined. Unlike @racket[margin-note], @racket[margin-note*] can be