From 35e6c893ec1f63aa2d1b0a5f128b9a6ab95f4b8c Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 23 Jul 2015 15:34:27 -0700 Subject: Parsing: toKey: strip off outer brackets. This makes keys with extra space at the beginning and end work: e.g. [foo]: bar [ foo ] will now be a link to bar (it wasn't before). --- src/Text/Pandoc/Parsing.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs index 5dc991be2..c316e9220 100644 --- a/src/Text/Pandoc/Parsing.hs +++ b/src/Text/Pandoc/Parsing.hs @@ -178,7 +178,7 @@ import Text.Parsec hiding (token) import Text.Parsec.Pos (newPos) import Data.Char ( toLower, toUpper, ord, chr, isAscii, isAlphaNum, isHexDigit, isSpace ) -import Data.List ( intercalate, transpose ) +import Data.List ( intercalate, transpose, isSuffixOf ) import Text.Pandoc.Shared import qualified Data.Map as M import Text.TeXMath.Readers.TeX.Macros (applyMacros, Macro, @@ -1063,7 +1063,9 @@ type NoteTable' = [(String, F Blocks)] -- used in markdown reader newtype Key = Key String deriving (Show, Read, Eq, Ord) toKey :: String -> Key -toKey = Key . map toLower . unwords . words +toKey = Key . map toLower . unwords . words . unbracket + where unbracket ('[':xs) | "]" `isSuffixOf` xs = take (length xs - 1) xs + unbracket xs = xs type KeyTable = M.Map Key Target -- cgit v1.2.3