aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2015-09-13 16:08:49 -0700
committerSean Whitton <spwhitton@spwhitton.name>2015-09-13 16:08:49 -0700
commit39d4085e124a80d4eda6838753e73b26b17ed14f (patch)
treea04799935fb94d6023e30b1fbf4b922ac265588c
downloadpandoc-citeproc-preamble-39d4085e124a80d4eda6838753e73b26b17ed14f.tar.gz
pandoc-citeproc-preamble proof of concept
-rw-r--r--LICENSE30
-rw-r--r--Setup.hs2
-rw-r--r--pandoc-citeproc-preamble.cabal23
-rw-r--r--src/pandoc-citeproc-preamble.hs24
-rw-r--r--stack.yaml5
5 files changed, 84 insertions, 0 deletions
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:
+- '.'