From 643d9ceb308c206a6e572c7c555168ff0ca60bc1 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Fri, 27 Mar 2015 15:40:42 -0700 Subject: Fix #5: Verse typesetting Thanks to the pandoc-discussion thread at , line breaks in verse have been converted to s, which enables the CSS to style them with hanging indents, given a too-small viewport. This commit also includes a makefile edit to reflect this change, and the Haskell source and executable of the pandoc filter. --- trunk/versify.hs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 trunk/versify.hs (limited to 'trunk/versify.hs') diff --git a/trunk/versify.hs b/trunk/versify.hs new file mode 100644 index 0000000..def041c --- /dev/null +++ b/trunk/versify.hs @@ -0,0 +1,15 @@ +import Text.Pandoc.JSON +import Data.List.Split + +main :: IO () +main = toJSONFilter transformVerseParas + +transformVerseParas :: Block -> Block +transformVerseParas (Para xs) + | LineBreak `elem` xs = Para (addLineSpans xs) + | otherwise = Para xs +transformVerseParas x = x + +addLineSpans :: [Inline] -> [Inline] +addLineSpans = map encloseInSpan . splitWhen (== LineBreak) + where encloseInSpan = Span("", ["line"], []) -- cgit 1.4.1-21-gabe81