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).
This commit is contained in:
John MacFarlane 2015-07-23 15:34:27 -07:00
parent 5db4787330
commit 35e6c893ec

View file

@ -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