From 39d4085e124a80d4eda6838753e73b26b17ed14f Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sun, 13 Sep 2015 16:08:49 -0700 Subject: pandoc-citeproc-preamble proof of concept --- LICENSE | 30 ++++++++++++++++++++++++++++++ Setup.hs | 2 ++ pandoc-citeproc-preamble.cabal | 23 +++++++++++++++++++++++ src/pandoc-citeproc-preamble.hs | 24 ++++++++++++++++++++++++ stack.yaml | 5 +++++ 5 files changed, 84 insertions(+) create mode 100644 LICENSE create mode 100644 Setup.hs create mode 100644 pandoc-citeproc-preamble.cabal create mode 100644 src/pandoc-citeproc-preamble.hs create mode 100644 stack.yaml diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e253c24 --- /dev/null +++ b/LICENSE @@ -0,0 +1,30 @@ +Copyright (c) Sean Whitton, 2015 + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of Your name here nor the names of other + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Setup.hs b/Setup.hs new file mode 100644 index 0000000..9a994af --- /dev/null +++ b/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/pandoc-citeproc-preamble.cabal b/pandoc-citeproc-preamble.cabal new file mode 100644 index 0000000..119dc5e --- /dev/null +++ b/pandoc-citeproc-preamble.cabal @@ -0,0 +1,23 @@ +name: pandoc-citeproc-preamble +version: 0.1.0.0 +synopsis: Initial project template from stack +description: Please see README.md +homepage: https://github.com/spwhitton/pandoc-citeproc-preamble +license: BSD3 +license-file: LICENSE +author: Sean Whitton +maintainer: spwhitton@spwhitton.name +category: Text +build-type: Simple +cabal-version: >=1.10 + +executable pandoc-citeproc-preamble + hs-source-dirs: src + main-is: pandoc-citeproc-preamble.hs + build-depends: base + , pandoc-types + default-language: Haskell2010 + +source-repository head + type: git + location: https://github.com/spwhitton/pandoc-citeproc-preamble diff --git a/src/pandoc-citeproc-preamble.hs b/src/pandoc-citeproc-preamble.hs new file mode 100644 index 0000000..a72314c --- /dev/null +++ b/src/pandoc-citeproc-preamble.hs @@ -0,0 +1,24 @@ +import Text.Pandoc.JSON + +preamble = [ RawBlock (Format "latex") "\\section*{References}" + , Para [ RawInline (Format "tex") "\\setlength{\\parindent}{-0.2in}" + , Space + , RawInline (Format "tex") "\\setlength{\\leftskip}{0.2in}" + , Space + , RawInline (Format "tex") "\\setlength{\\parskip}{8pt}" + , Space + , RawInline (Format "tex") "\\vspace*{-0.2in}" + , Space + , RawInline (Format "tex") "\\noindent" + ] + ] + +insertPreamble :: [Block] -> [Block] +insertPreamble = foldr step [] + where + step refs@(Div (_, ["references"], _) _) xs = preamble ++ refs : xs + step x xs = x:xs + +main = toJSONFilter preamble + where + preamble (Pandoc meta blocks) = Pandoc meta (insertPreamble blocks) diff --git a/stack.yaml b/stack.yaml new file mode 100644 index 0000000..8128d15 --- /dev/null +++ b/stack.yaml @@ -0,0 +1,5 @@ +extra-deps: [] +resolver: lts-3.4 +flags: {} +packages: +- '.' -- cgit v1.2.3