aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2016-06-25 14:04:47 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2016-06-25 14:04:47 -0700
commit38c97320ef551e63efdd4637dbbd6ba2666a1d66 (patch)
tree74fdfae19bd356886b4129c93ae99430da8d5649
parent0f9c6c4db0d1c352e2c64d8237252923820be9f4 (diff)
downloadpandoc-38c97320ef551e63efdd4637dbbd6ba2666a1d66.tar.gz
Textile reader: Fix overly aggressive interpretation as images.
Spaces are not allowed in the image URL in textile. Closes #2998.
-rw-r--r--src/Text/Pandoc/Readers/Textile.hs11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/Text/Pandoc/Readers/Textile.hs b/src/Text/Pandoc/Readers/Textile.hs
index 17c6583ff..3b8278e27 100644
--- a/src/Text/Pandoc/Readers/Textile.hs
+++ b/src/Text/Pandoc/Readers/Textile.hs
@@ -63,7 +63,7 @@ import Text.Pandoc.Readers.LaTeX ( rawLaTeXInline, rawLaTeXBlock )
import Text.HTML.TagSoup (parseTags, innerText, fromAttrib, Tag(..))
import Text.HTML.TagSoup.Match
import Data.List ( intercalate )
-import Data.Char ( digitToInt, isUpper)
+import Data.Char ( digitToInt, isUpper )
import Control.Monad ( guard, liftM, when )
import Text.Pandoc.Compat.Monoid ((<>))
import Text.Printf
@@ -540,8 +540,8 @@ image = try $ do
let attr = case lookup "style" kvs of
Just stls -> (ident, cls, pickStylesToKVs ["width", "height"] stls)
Nothing -> (ident, cls, kvs)
- src <- manyTill anyChar' (lookAhead $ oneOf "!(")
- alt <- option "" (try $ (char '(' >> manyTill anyChar' (char ')')))
+ src <- many1 (noneOf " \t\n\r!(")
+ alt <- option "" $ try $ char '(' *> manyTill anyChar (char ')')
char '!'
return $ B.imageWith attr src alt (B.str alt)
@@ -639,10 +639,7 @@ simpleInline :: Parser [Char] ParserState t -- ^ surrounding parser
-> (Inlines -> Inlines) -- ^ Inline constructor
-> Parser [Char] ParserState Inlines -- ^ content parser (to be used repeatedly)
simpleInline border construct = try $ do
- st <- getState
- pos <- getPosition
- let afterString = stateLastStrPos st == Just pos
- guard $ not afterString
+ notAfterString
border *> notFollowedBy (oneOf " \t\n\r")
attr <- attributes
body <- trimInlines . mconcat <$>