git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #3012 from tarleb/org-drop-ugly-pragma

Org reader: replace ugly code with view pattern

commit46f3deb2480b8b45bfc5f8a067cdcb4c92f9dd6e authorJohn MacFarlane <jgm@berkeley.edu> dateMon 4 Jul 2016, 10:03 (10 years ago) parente548b8df417fec
1 file changed+4−5
src/Text/Pandoc/Readers/Org/Blocks.hs+4−5
src/Text/Pandoc/Readers/Org/Blocks.hs+4−5
@@ -1,6 +1,6 @@
11{-# LANGUAGE FlexibleContexts #-}
22{-# LANGUAGE RecordWildCards #-}
3−{-# OPTIONS_GHC -fno-warn-overlapping-patterns #-}
3+{-# LANGUAGE ViewPatterns #-}
44{-
55Copyright (C) 2014-2016 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
66
@@ -54,7 +54,6 @@ import Data.Char ( isSpace, toLower, toUpper)
5454import Data.List ( foldl', intersperse, isPrefixOf )
5555import qualified Data.Map as M
5656import Data.Maybe ( fromMaybe, isNothing )
57−import qualified Data.Sequence as S
5857import Network.HTTP ( urlEncode )
5958
6059--
@@ -142,7 +141,7 @@ headlineToBlocks hdln@(Headline {..}) = do
142141 _ | any isArchiveTag headlineTags -> archivedHeadlineToBlocks hdln
143142 _ | isCommentTitle headlineText -> return mempty
144143 _ | headlineLevel >= maxHeadlineLevels -> headlineToHeaderWithList hdln
145− _ -> headlineToHeaderWithContents hdln
144+ _ | otherwise -> headlineToHeaderWithContents hdln
146145
147146isNoExportTag :: Tag -> Bool
148147isNoExportTag = (== toTag "noexport")
@@ -154,8 +153,8 @@ isArchiveTag = (== toTag "ARCHIVE")
154153-- FIXME: This accesses builder internals not intended for use in situations
155154-- like these. Replace once keyword parsing is supported.
156155isCommentTitle :: Inlines -> Bool
157−isCommentTitle xs = (B.Many . S.take 1 . B.unMany) xs == B.str "COMMENT"
158−isCommentTitle _ = False
156+isCommentTitle (B.toList -> (Str "COMMENT":_)) = True
157+isCommentTitle _ = False
159158
160159archivedHeadlineToBlocks :: Headline -> OrgParser Blocks
161160archivedHeadlineToBlocks hdln = do