Skip to content

Commit

Permalink
Modify toKnownFormat to ignore case
Browse files Browse the repository at this point in the history
  • Loading branch information
despresc committed Sep 7, 2020
1 parent 7a3d0d4 commit 25ec7d9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Text/Pandoc/Format.hs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import qualified Data.Map as Map
import Data.Set ( Set )
import qualified Data.Set as Set
import Data.Text ( Text )
import qualified Data.Text as Text
import GHC.Generics ( Generic )
import Prelude hiding ( not
, any
Expand Down Expand Up @@ -143,13 +144,16 @@ data KnownFormat
data Format = KnownFormat KnownFormat | CustomFormat Text
deriving (Eq, Ord, Read, Show, Typeable, Data, Generic)

-- | Attempt to identify the specifying string of a known format.
-- | Attempt to identify the specifying string of a known
-- format. Ignores case.
--
-- > toKnownFormat "asciidoc" = Just AsciiDoc
-- > toKnownFormat "jats_archiving" = Just JatsArchiving
-- > toKnownFormat "latex" = Just LaTeX
-- > toKnownFormat "lAtEx" = Just LaTeX
-- > toKnownFormat "custom" = Nothing
toKnownFormat :: Text -> Maybe KnownFormat
toKnownFormat = flip Map.lookup m
toKnownFormat = flip Map.lookup m . Text.toLower
where
m = Map.fromList
[ ("asciidoc" , AsciiDoc)
Expand Down

0 comments on commit 25ec7d9

Please sign in to comment.