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
This commit is contained in:
fiddlosopher 2007-01-06 20:47:00 +00:00
parent 58dcef0625
commit 233148f963
11 changed files with 44 additions and 12 deletions

13
debian/changelog vendored
View file

@ -73,15 +73,20 @@ pandoc (0.3) unstable; urgency=low
+ Revised inline code parsing in Markdown reader to conform to
markdown standard. Now any number of `s can begin inline code,
which will end with the same number of `s. For example, to
have two backticks as code, write ``` `` ```.
have two backticks as code, write ``` `` ```. Modified Markdown
writer accordingly.
+ Modified HTML reader to skip a newline following a <br> tag.
Otherwise the newline will be treated as a space at the beginning
of the next line.
+ Fixed bug in text-wrapping routine in Markdown and RST writers.
Now LineBreaks no longer cause wrapping problems.
+ Fixed bug with inline Code in Markdown writer. Now it's guaranteed
that enough `'s will be used, depending on the content.
+ Supported hexadecimal numerical entity references as well as
decimal ones.
+ 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.
* Made handling of code blocks more consistent. Previously, some
readers allowed trailing newlines, while others stripped them.
Now, all readers strip trailing newlines in code blocks. Writers

View file

@ -696,17 +696,23 @@ endline = try (do
-- links
--
-- a reference label for a link
reference = do
rawLabel = try $ do
char labelStart
notFollowedBy (char noteStart)
-- allow for embedded brackets:
label <- manyTill ((do{res <- reference;
return $ [Str "["] ++ res ++ [Str "]"]}) <|>
count 1 inline)
(char labelEnd)
return (normalizeSpaces (concat label))
raw <- manyTill (do{res <- rawLabel; return ("[" ++ res ++ "]")} <|>
count 1 anyChar) (char labelEnd)
return $ concat raw
-- a reference label for a link
reference = try $ do
notFollowedBy (try (do{char labelStart; char noteStart}))
raw <- rawLabel
oldInput <- getInput
setInput raw
label <- many inline
setInput oldInput
return (normalizeSpaces label)
-- source for a link, with optional title
source = try (do
char srcStart

View file

@ -270,6 +270,7 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] ["John MacFarlane
, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] (Src "/url/" "title preceded by a tab"),Str "."]
, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] (Src "/url/" "title with &quot;quotes&quot; in it")]
, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] (Src "/url/" "title with single quotes")]
, Para [Link [Str "with",Str "_",Str "underscore"] (Src "/url/with_underscore" "")]
, Para [Link [Str "Email",Space,Str "link"] (Src "mailto:nobody@nowhere.net" "")]
, Para [Link [Str "Empty"] (Src "" ""),Str "."]
, Header 2 [Str "Reference"]

View file

@ -502,6 +502,8 @@ Just a [URL](/url/).
[URL and title](/url/ 'title with single quotes')
[with_underscore](/url/with_underscore)
[Email link](mailto:nobody@nowhere.net)
[Empty]().

View file

@ -815,6 +815,9 @@ Cat &amp; 1 \\ \hline
<para>
<ulink url="/url/">URL and title</ulink>
</para>
<para>
<ulink url="/url/with_underscore">with_underscore</ulink>
</para>
<para>
<email>nobody@nowhere.net</email>
</para>

View file

@ -647,6 +647,9 @@ Cat &amp; 1 \\ \hline
<p>
<a href="/url/" title="title with single quotes">URL and title</a>
</p>
<p>
<a href="/url/with_underscore">with_underscore</a>
</p>
<p>
<script type="text/javascript">
<!--

View file

@ -492,6 +492,8 @@ Just a \href{/url/}{URL}.
\href{/url/}{URL and title}
\href{/url/with_underscore}{with\_underscore}
\href{mailto:nobody@nowhere.net}{Email link}
\href{}{Empty}.

View file

@ -514,6 +514,8 @@ Just a [URL](/url/).
[URL and title](/url/ "title with single quotes")
[with\_underscore](/url/with_underscore)
[Email link](mailto:nobody@nowhere.net)
[Empty]().

View file

@ -270,6 +270,7 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] ["John MacFarlane
, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] (Src "/url/" "title preceded by a tab"),Str "."]
, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] (Src "/url/" "title with &quot;quotes&quot; in it")]
, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] (Src "/url/" "title with single quotes")]
, Para [Link [Str "with",Str "_",Str "underscore"] (Src "/url/with_underscore" "")]
, Para [Link [Str "Email",Space,Str "link"] (Src "mailto:nobody@nowhere.net" "")]
, Para [Link [Str "Empty"] (Src "" ""),Str "."]
, Header 2 [Str "Reference"]

View file

@ -616,6 +616,8 @@ Just a `URL`_.
`URL and title`_
`with\_underscore`_
`Email link`_
`Empty`_.
@ -739,6 +741,7 @@ indented.
.. _quoted link: http://example.com/?foo=1&bar=2
.. _URL: /url/
.. _URL and title: /url/
.. _with\_underscore: /url/with_underscore
.. _Email link: mailto:nobody@nowhere.net
.. _Empty:
.. _bar: /url/

View file

@ -271,6 +271,10 @@ URL and title
URL and title
}}}
\par}
{\pard \f0 \sa180 \li0 \fi0 {\field{\*\fldinst{HYPERLINK "/url/with_underscore"}}{\fldrslt{\ul
with_underscore
}}}
\par}
{\pard \f0 \sa180 \li0 \fi0 {\field{\*\fldinst{HYPERLINK "mailto:nobody@nowhere.net"}}{\fldrslt{\ul
Email link
}}}