commit 06e254f169ffa5a1bf7dbd42fd923d00809c6853
parent c34a69c62386db1770fb45e57af55e9e0dd44ef5
Author: Jay McCarthy <jay.mccarthy@gmail.com>
Date: Thu, 16 Jun 2016 16:37:01 -0400
Adding elsarticle
Diffstat:
5 files changed, 81 insertions(+), 0 deletions(-)
diff --git a/scribble-lib/scribble/elsarticle/.gitignore b/scribble-lib/scribble/elsarticle/.gitignore
@@ -0,0 +1,2 @@
+# to avoid committing it by accident, since we can't distribute it
+/elsarticle.cls
diff --git a/scribble-lib/scribble/elsarticle/elsarticle.tex b/scribble-lib/scribble/elsarticle/elsarticle.tex
@@ -0,0 +1,5 @@
+\newcommand{\ELSauthor}[1]{\author{#1}}
+\newcommand{\ELSaddress}[1]{\address{#1}}
+\newcommand{\ELSemail}[1]{\ead{#1}}
+
+\newcommand{\ELSabstract}[1]{\begin{abstract}#1\end{abstract}}
diff --git a/scribble-lib/scribble/elsarticle/lang.rkt b/scribble-lib/scribble/elsarticle/lang.rkt
@@ -0,0 +1,68 @@
+#lang racket/base
+(require scribble/doclang
+ scribble/core
+ racket/file
+ (except-in scribble/base author)
+ (prefix-in s/b: scribble/base)
+ scribble/decode
+ "../private/defaults.rkt"
+ setup/collects
+ scribble/html-properties
+ scribble/latex-properties
+ scribble/latex-prefix
+ racket/stxparam
+ net/ftp
+ file/gunzip
+ (for-syntax racket/base
+ racket/list
+ racket/stxparam-exptime))
+
+(module test racket/base)
+
+(provide (except-out (all-from-out scribble/doclang) #%module-begin)
+ (all-from-out scribble/base)
+ (rename-out [module-begin #%module-begin])
+ frontmatter
+ abstract author email address)
+
+(define-syntax (module-begin stx)
+ ;; No options, currently, but keep in case we want to support some:
+ (syntax-case* stx () (lambda (a b) (eq? (syntax-e a) (syntax-e b)))
+ [(_ id ws . body)
+ ;; Skip intraline whitespace to find options:
+ (and (string? (syntax-e #'ws))
+ (regexp-match? #rx"^ *$" (syntax-e #'ws)))
+ #'(module-begin id . body)]
+ [(_ id . body)
+ #'(#%module-begin id (post-process) () . body)]))
+
+(define ((post-process) doc)
+ (add-defaults doc
+ (string->bytes/utf-8 (string-append "\\documentclass{elsarticle}\n"
+ unicode-encoding-packages))
+ (scribble-file "elsarticle/style.tex")
+ '()
+ #f))
+
+(define elsarticle-extras
+ (let ([abs (lambda (s)
+ (path->collects-relative
+ (collection-file-path s "scribble" "elsarticle")))])
+ (list
+ (make-tex-addition (abs "elsarticle.tex")))))
+
+(define (LaTeX-element i)
+ (λ strs
+ (make-element (style i elsarticle-extras)
+ ;; XXX maybe decode-content
+ (decode-content strs))))
+
+(define abstract (LaTeX-element "ELSabstract"))
+(define author (LaTeX-element "ELSauthor"))
+(define address (LaTeX-element "ELSaddress"))
+(define email (LaTeX-element "ELSemail"))
+
+(define (frontmatter #:authors as
+ #:abstract a)
+ (paragraph (style 'author '())
+ (append as (list a))))
diff --git a/scribble-lib/scribble/elsarticle/lang/reader.rkt b/scribble-lib/scribble/elsarticle/lang/reader.rkt
@@ -0,0 +1,3 @@
+#lang s-exp scribble/base/reader
+scribble/elsarticle/lang
+#:wrapper1 (lambda (t) (cons 'doc (t)))
diff --git a/scribble-lib/scribble/elsarticle/style.tex b/scribble-lib/scribble/elsarticle/style.tex
@@ -0,0 +1,3 @@
+
+\renewcommand{\titleAndVersionAndAuthors}[3]{\begin{frontmatter}\title{#1}#3\end{frontmatter}}
+\renewcommand{\titleAndEmptyVersionAndAuthors}[3]{\titleAndVersionAndAuthors{#1}{#1}{#3}}