git.iko.soy/typeable/pandoc
on master help sign in
Fixed bug in Markdown reader's handling of underscores and other

inline formatting markers inside reference labels: for example, in '[A_B]: /url/a_b', the material between underscores was being parsed as emphasized inlines. git-svn-id: https://pandoc.googlecode.com/svn/trunk@442 788f1e2b-df1e-0410-8736-df70ead52e1b

commit233148f9638f637871391cbed239068aeddb6cca authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateSat 6 Jan 2007, 20:47 (20 years ago) parent58dcef0
11 files changed+44−12
debian/changelog+9−4 src/Text/Pandoc/Readers/Markdown.hs+14−8 tests/testsuite.native+1 tests/testsuite.txt+2 tests/writer.docbook+3 tests/writer.html+3 tests/writer.latex+2 tests/writer.markdown+2 tests/writer.native+1 tests/writer.rst+3 tests/writer.rtf+4
debian/changelog+9−4
@@ -73,15 +73,20 @@ pandoc (0.3) unstable; urgency=low
7373 + Revised inline code parsing in Markdown reader to conform to
7474 markdown standard. Now any number of `s can begin inline code,
7575 which will end with the same number of `s. For example, to
76− have two backticks as code, write ``` `` ```.
76+ have two backticks as code, write ``` `` ```. Modified Markdown
77+ writer accordingly.
7778 + Modified HTML reader to skip a newline following a <br> tag.
7879 Otherwise the newline will be treated as a space at the beginning
7980 of the next line.
8081 + Fixed bug in text-wrapping routine in Markdown and RST writers.
8182 Now LineBreaks no longer cause wrapping problems.
82− + Fixed bug with inline Code in Markdown writer. Now it's guaranteed
83− that enough `'s will be used, depending on the content.
84−
83+ + Supported hexadecimal numerical entity references as well as
84+ decimal ones.
85+ + Fixed bug in Markdown reader's handling of underscores and other
86+ inline formatting markers inside reference labels: for example,
87+ in '[A_B]: /url/a_b', the material between underscores was being
88+ parsed as emphasized inlines.
89+
8590 * Made handling of code blocks more consistent. Previously, some
8691 readers allowed trailing newlines, while others stripped them.
8792 Now, all readers strip trailing newlines in code blocks. Writers
src/Text/Pandoc/Readers/Markdown.hs+14−8
@@ -696,17 +696,23 @@ endline = try (do
696696-- links
697697--
698698
699−-- a reference label for a link
700−reference = do
699+rawLabel = try $ do
701700 char labelStart
702− notFollowedBy (char noteStart)
703701 -- allow for embedded brackets:
704− label <- manyTill ((do{res <- reference;
705− return $ [Str "["] ++ res ++ [Str "]"]}) <|>
706− count 1 inline)
707− (char labelEnd)
708− return (normalizeSpaces (concat label))
702+ raw <- manyTill (do{res <- rawLabel; return ("[" ++ res ++ "]")} <|>
703+ count 1 anyChar) (char labelEnd)
704+ return $ concat raw
709705
706+-- a reference label for a link
707+reference = try $ do
708+ notFollowedBy (try (do{char labelStart; char noteStart}))
709+ raw <- rawLabel
710+ oldInput <- getInput
711+ setInput raw
712+ label <- many inline
713+ setInput oldInput
714+ return (normalizeSpaces label)
715+
710716-- source for a link, with optional title
711717source = try (do
712718 char srcStart
tests/testsuite.native+1
@@ -270,6 +270,7 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] ["John MacFarlane
270270, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] (Src "/url/" "title preceded by a tab"),Str "."]
271271, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] (Src "/url/" "title with &quot;quotes&quot; in it")]
272272, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] (Src "/url/" "title with single quotes")]
273+, Para [Link [Str "with",Str "_",Str "underscore"] (Src "/url/with_underscore" "")]
273274, Para [Link [Str "Email",Space,Str "link"] (Src "mailto:nobody@nowhere.net" "")]
274275, Para [Link [Str "Empty"] (Src "" ""),Str "."]
275276, Header 2 [Str "Reference"]
tests/testsuite.txt+2
@@ -502,6 +502,8 @@ Just a [URL](/url/).
502502
503503[URL and title](/url/ 'title with single quotes')
504504
505+[with_underscore](/url/with_underscore)
506+
505507[Email link](mailto:nobody@nowhere.net)
506508
507509[Empty]().
tests/writer.docbook+3
@@ -815,6 +815,9 @@ Cat &amp; 1 \\ \hline
815815 <para>
816816 <ulink url="/url/">URL and title</ulink>
817817 </para>
818+ <para>
819+ <ulink url="/url/with_underscore">with_underscore</ulink>
820+ </para>
818821 <para>
819822 <email>nobody@nowhere.net</email>
820823 </para>
tests/writer.html+3
@@ -647,6 +647,9 @@ Cat &amp; 1 \\ \hline
647647<p>
648648 <a href="/url/" title="title with single quotes">URL and title</a>
649649</p>
650+<p>
651+ <a href="/url/with_underscore">with_underscore</a>
652+</p>
650653<p>
651654 <script type="text/javascript">
652655<!--
tests/writer.latex+2
@@ -492,6 +492,8 @@ Just a \href{/url/}{URL}.
492492
493493\href{/url/}{URL and title}
494494
495+\href{/url/with_underscore}{with\_underscore}
496+
495497\href{mailto:nobody@nowhere.net}{Email link}
496498
497499\href{}{Empty}.
tests/writer.markdown+2
@@ -514,6 +514,8 @@ Just a [URL](/url/).
514514
515515[URL and title](/url/ "title with single quotes")
516516
517+[with\_underscore](/url/with_underscore)
518+
517519[Email link](mailto:nobody@nowhere.net)
518520
519521[Empty]().
tests/writer.native+1
@@ -270,6 +270,7 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] ["John MacFarlane
270270, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] (Src "/url/" "title preceded by a tab"),Str "."]
271271, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] (Src "/url/" "title with &quot;quotes&quot; in it")]
272272, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] (Src "/url/" "title with single quotes")]
273+, Para [Link [Str "with",Str "_",Str "underscore"] (Src "/url/with_underscore" "")]
273274, Para [Link [Str "Email",Space,Str "link"] (Src "mailto:nobody@nowhere.net" "")]
274275, Para [Link [Str "Empty"] (Src "" ""),Str "."]
275276, Header 2 [Str "Reference"]
tests/writer.rst+3
@@ -616,6 +616,8 @@ Just a `URL`_.
616616
617617`URL and title`_
618618
619+`with\_underscore`_
620+
619621`Email link`_
620622
621623`Empty`_.
@@ -739,6 +741,7 @@ indented.
739741.. _quoted link: http://example.com/?foo=1&bar=2
740742.. _URL: /url/
741743.. _URL and title: /url/
744+.. _with\_underscore: /url/with_underscore
742745.. _Email link: mailto:nobody@nowhere.net
743746.. _Empty:
744747.. _bar: /url/
tests/writer.rtf+4
@@ -271,6 +271,10 @@ URL and title
271271URL and title
272272}}}
273273\par}
274+{\pard \f0 \sa180 \li0 \fi0 {\field{\*\fldinst{HYPERLINK "/url/with_underscore"}}{\fldrslt{\ul
275+with_underscore
276+}}}
277+\par}
274278{\pard \f0 \sa180 \li0 \fi0 {\field{\*\fldinst{HYPERLINK "mailto:nobody@nowhere.net"}}{\fldrslt{\ul
275279Email link
276280}}}