From 31ff97f502e814767d0ec8a07b7666ca49294ef8 Mon Sep 17 00:00:00 2001 From: shuhung Date: Wed, 2 Jan 2019 13:44:57 -0600 Subject: [PATCH] Add email-string to typeset email with exact-chars (#187) Closes #185. --- .../scribblings/scribble/acmart.scrbl | 22 +++++++++++++++++-- scribble-lib/scribble/acmart.rkt | 22 +++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/scribble-doc/scribblings/scribble/acmart.scrbl b/scribble-doc/scribblings/scribble/acmart.scrbl index 657af313..f0cc2ab6 100644 --- a/scribble-doc/scribblings/scribble/acmart.scrbl +++ b/scribble-doc/scribblings/scribble/acmart.scrbl @@ -168,6 +168,15 @@ Specifies a subtitle.} Specifies an author with an optional email address, affiliation, and/or orcid. +@codeblock|{ + #lang scribble/acmart + @title{Title} + @author["Unboxed Value" + #:email (list (email "user@server.com") + (email-string "case--Int#@GHC.Prim.info"))]} + + @abstract{abstracting abstract title} +}| } @deftogether[( @@ -197,9 +206,18 @@ screen version of the image links to the badge authority. } -@defproc[(email [text pre-content?] ...) - email?]{ +@deftogether[( +@defproc[(email [text pre-content?] ...) email?] +@defproc[(email-string [text string?] ...) email?] +)]{ Creates an @racket[email?] object for use with @racket[author]. + + @racket[email-string] is like @racket[email] + except that @racket[email-string] only takes + @tech[#:doc '(lib "scribblings/reference/reference.scrbl") #:key "string"]{strings}, + escapes all @tt{%} and @tt{#} characters + in the arguments and typesets the email address with the + @racket['exact-chars] style. } @defproc[(email? [email any/c]) boolean?]{ diff --git a/scribble-lib/scribble/acmart.rkt b/scribble-lib/scribble/acmart.rkt index 103ce33c..6ce76623 100644 --- a/scribble-lib/scribble/acmart.rkt +++ b/scribble-lib/scribble/acmart.rkt @@ -3,6 +3,7 @@ (require setup/collects racket/contract/base racket/list + racket/string scribble/core scribble/base scribble/decode @@ -62,6 +63,9 @@ [email (->* () #:rest (listof pre-content?) email?)] + [email-string (->* () + #:rest (listof string?) + email?)] [email? (-> any/c boolean?)] [affiliation (->* () (#:position (or/c pre-content? #f) @@ -367,11 +371,29 @@ (define (email . text) (author-email text)) +(define (email-string . text) + (define text-escaped + (for/list ([str (in-list text)]) + (escape-email-string str))) + (author-email + (list + (make-element + (make-style #f '(exact-chars)) + text-escaped)))) + (define (convert-email email) (make-element (make-style "SAuthorEmail" command-props) (decode-content (email-text email)))) +(define escape-email-map + #(("#" . "\\#") + ("%" . "\\%"))) +(define (escape-email-string str) + (for/fold ([str str]) + ([escape-map (in-vector escape-email-map)]) + (string-replace str (car escape-map) (cdr escape-map)))) + (define (affiliation #:position [position #f] #:institution [institution #f] #:street-address [street-address #f]