about summary refs log tree commit diff stats
path: root/trunk/versify.hs
blob: 48e9c00a20bbda5124f8ab57c8ef0e97d69122b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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"], [])