aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-07-23 15:34:27 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2015-07-23 15:34:27 -0700
commit35e6c893ec1f63aa2d1b0a5f128b9a6ab95f4b8c (patch)
tree67f9305a5906ea7bc29f2c5f5eb6664c8e84dce2
parent5db478733034433e7875853a126b43a7f5f6de84 (diff)
downloadpandoc-35e6c893ec1f63aa2d1b0a5f128b9a6ab95f4b8c.tar.gz
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).
-rw-r--r--src/Text/Pandoc/Parsing.hs6
1 files 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