Skip to content

Commit

Permalink
pandoc-citeproc-preamble proof of concept
Browse files Browse the repository at this point in the history
  • Loading branch information
spwhitton committed Sep 13, 2015
0 parents commit 39d4085
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 0 deletions.
30 changes: 30 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 2 additions & 0 deletions Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain
23 changes: 23 additions & 0 deletions pandoc-citeproc-preamble.cabal
Original file line number Diff line number Diff line change
@@ -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: [email protected]
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
24 changes: 24 additions & 0 deletions src/pandoc-citeproc-preamble.hs
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 5 additions & 0 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
extra-deps: []
resolver: lts-3.4
flags: {}
packages:
- '.'

0 comments on commit 39d4085

Please sign in to comment.