From 667b8f62eafd6c474bb2adaf1cafa47378247db1 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Sat, 11 Jul 2009 01:08:31 +0000 Subject: Improved clarity of titleTransform in RST reader. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1592 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/Text/Pandoc/Readers/RST.hs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs index 4fe6ada5e..884d6f0e6 100644 --- a/src/Text/Pandoc/Readers/RST.hs +++ b/src/Text/Pandoc/Readers/RST.hs @@ -75,14 +75,12 @@ promoteHeaders _ [] = [] -- promote all the other headers. titleTransform :: [Block] -- ^ list of blocks -> ([Block], [Inline]) -- ^ modified list of blocks, title -titleTransform ((Header 1 head1):(Header 2 head2):rest) = -- title subtitle - if (any (isHeader 1) rest) || (any (isHeader 2) rest) - then ((Header 1 head1):(Header 2 head2):rest, []) - else ((promoteHeaders 2 rest), head1 ++ [Str ":", Space] ++ head2) -titleTransform ((Header 1 head1):rest) = -- title, no subtitle - if (any (isHeader 1) rest) - then ((Header 1 head1):rest, []) - else ((promoteHeaders 1 rest), head1) +titleTransform ((Header 1 head1):(Header 2 head2):rest) | + not (any (isHeader 1) rest || any (isHeader 2) rest) = -- both title & subtitle + (promoteHeaders 2 rest, head1 ++ [Str ":", Space] ++ head2) +titleTransform ((Header 1 head1):rest) | + not (any (isHeader 1) rest) = -- title, no subtitle + (promoteHeaders 1 rest, head1) titleTransform blocks = (blocks, []) parseRST :: GenParser Char ParserState Pandoc -- cgit v1.2.3