@@ -34,7 +34,7 @@ import Text.Pandoc.Definition
34import Text.Pandoc.Shared
34import Text.Pandoc.Shared
35import Text.Pandoc.Parsing
35import Text.Pandoc.Parsing
36import Text.ParserCombinators.Parsec
36import Text.ParserCombinators.Parsec
37−import Control.Monad ( when )
37+import Control.Monad ( when, liftM )
38import Data.List ( findIndex, intercalate, transpose, sort, deleteFirstsBy )
38import Data.List ( findIndex, intercalate, transpose, sort, deleteFirstsBy )
39import qualified Data.Map as M
39import qualified Data.Map as M
40import Text.Printf ( printf )
40import Text.Printf ( printf )
@@ -540,9 +540,15 @@ noteBlock = try $ do
540 return $ replicate (sourceLine endPos - sourceLine startPos) '\n'
540 return $ replicate (sourceLine endPos - sourceLine startPos) '\n'
542noteMarker :: GenParser Char ParserState [Char]
542noteMarker :: GenParser Char ParserState [Char]
546+ <|> (try $ char '#' >> liftM ('#':) simpleReferenceName')
543−noteMarker = char '[' >> (many1 digit <|> count 1 (oneOf "#*")) >>~ char ']'
547+ <|> count 1 (oneOf "#*")
546-- reference key
552-- reference key
@@ -557,13 +563,20 @@ unquotedReferenceName = try $ do
557 label' <- many1Till inline (lookAhead $ char ':')
563 label' <- many1Till inline (lookAhead $ char ':')
558 return label'
564 return label'
566+-- Simple reference names are single words consisting of alphanumerics
567+-- plus isolated (no two adjacent) internal hyphens, underscores,
568+-- periods, colons and plus signs; no whitespace or other characters
560−isolated :: Char -> GenParser Char st Char
570+simpleReferenceName' :: GenParser Char st String
561−isolated ch = try $ char ch >>~ notFollowedBy (char ch)
571+simpleReferenceName' = do
573+ xs <- many $ alphaNum
574+ <|> (try $ oneOf "-_:+." >> lookAhead alphaNum)
563simpleReferenceName :: GenParser Char st [Inline]
577simpleReferenceName :: GenParser Char st [Inline]
564simpleReferenceName = do
578simpleReferenceName = do
565− raw <- many1 (alphaNum <|> isolated '-' <|> isolated '.' <|>
579+ raw <- simpleReferenceName'
566− (try $ char '_' >>~ lookAhead alphaNum))
567 return [Str raw]
580 return [Str raw]
569referenceName :: GenParser Char ParserState [Inline]
582referenceName :: GenParser Char ParserState [Inline]