diff options
author | John MacFarlane <jgm@berkeley.edu> | 2017-11-01 09:27:51 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-11-01 09:27:51 -0700 |
commit | ed3d46638425825de30aaa3d1152b9343292c315 (patch) | |
tree | 1cef0519e0412bae186b91beff3090b43875222e | |
parent | f1ebdb814514b998bbb650c9af58eb5cf4d09daa (diff) | |
download | pandoc-ed3d46638425825de30aaa3d1152b9343292c315.tar.gz |
Really fix #3989.
The previous fix only worked in certain cases.
Other cases with `>` in an HTML attribute broke.
-rw-r--r-- | src/Text/Pandoc/Readers/HTML.hs | 17 | ||||
-rw-r--r-- | test/command/3989.md | 2 |
2 files changed, 13 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs index e2be1c5bd..2b667c63c 100644 --- a/src/Text/Pandoc/Readers/HTML.hs +++ b/src/Text/Pandoc/Readers/HTML.hs @@ -1133,6 +1133,7 @@ htmlTag :: (HasReaderOptions st, Monad m) -> ParserT [Char] st m (Tag String, String) htmlTag f = try $ do lookAhead (char '<') + startpos <- getPosition inp <- getInput let ts = canonicalizeTags $ parseTagsOptions parseOptions{ optTagWarning = False @@ -1153,11 +1154,17 @@ htmlTag f = try $ do [] -> False (c:cs) -> isLetter c && all isNameChar cs - let endAngle = try $ do char '>' - pos <- getPosition - guard $ (sourceLine pos == ln && - sourceColumn pos >= col) || - sourceLine pos > ln + let endpos = if ln == 1 + then setSourceColumn startpos + (sourceColumn startpos + (col - 1)) + else setSourceColumn (setSourceLine startpos + (sourceLine startpos + (ln - 1))) + col + let endAngle = try $ + do char '>' + pos <- getPosition + guard $ pos >= endpos + let handleTag tagname = do -- basic sanity check, since the parser is very forgiving -- and finds tags in stuff like x<y) diff --git a/test/command/3989.md b/test/command/3989.md index 32b5e0574..bf078b2e4 100644 --- a/test/command/3989.md +++ b/test/command/3989.md @@ -1,7 +1,7 @@ ``` pandoc -f markdown -t native <span title="1st line of text <br> 2nd line of text">foo</span> -<span title="1st line of text <br> 2nd line of text">foo</span> + <span title="1st line of text <br> 2nd line of text">foo</span> ^D [Para [Span ("",[],[("title","1st line of text <br> 2nd line of text")]) [Str "foo"],SoftBreak,Span ("",[],[("title","1st line of text <br> 2nd line of text")]) [Str "foo"]]] ``` |