+ Fixed bug in markdown ordered list parsing. The problem was

that anyOrderedListStart did not check for a space following the
  ordered list marker. So, 'A.B. 2007' would be parsed as a list item,
  then fail because of the lack of space after 'A.' (required by
  orderedListStart). Resolves Issue #22.
+ Fixed a similar problem in RST reader.
+ Added regression test.


git-svn-id: https://pandoc.googlecode.com/svn/trunk@861 788f1e2b-df1e-0410-8736-df70ead52e1b
This commit is contained in:
fiddlosopher 2007-08-18 15:26:29 +00:00
parent fcda8d191b
commit e48f046aa0
13 changed files with 46 additions and 4 deletions

View file

@ -334,8 +334,9 @@ anyOrderedListStart = try $ do
if stateStrict state
then do many1 digit
char '.'
spaceChar
return (1, DefaultStyle, DefaultDelim)
else anyOrderedListMarker
else anyOrderedListMarker >>~ spaceChar
orderedListStart style delim = try $ do
optional newline -- if preceded by a Plain block in a list context
@ -346,7 +347,7 @@ orderedListStart style delim = try $ do
char '.'
return 1
else orderedListMarker style delim
oneOf spaceChars
spaceChar
skipSpaces
-- parse a line of a list item (start = parser for beginning of list item)

View file

@ -418,7 +418,7 @@ listItem start = try $ do
return parsed
orderedList = try $ do
(start, style, delim) <- lookAhead anyOrderedListMarker
(start, style, delim) <- lookAhead (anyOrderedListMarker >>~ spaceChar)
items <- many1 (listItem (orderedListStart style delim))
let items' = compactify items
return $ OrderedList (start, style, delim) items'
@ -551,7 +551,8 @@ endline = try $ do
-- parse potential list-starts at beginning of line differently in a list:
st <- getState
if ((stateParserContext st) == ListItemState)
then notFollowedBy' anyOrderedListMarker >> notFollowedBy' bulletListStart
then notFollowedBy (anyOrderedListMarker >> spaceChar) >>
notFollowedBy' bulletListStart
else return ()
return Space

View file

@ -178,6 +178,8 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] ["John MacFarlane
, OrderedList (1,DefaultStyle,DefaultDelim)
[ [ Plain [Str "Nested",Str "."] ]
] ] ]
, Para [Str "Should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "list",Space,Str "item:"]
, Para [Str "M",Str ".",Str "A",Str ".",Space,Str "2007"]
, HorizontalRule
, Header 1 [Str "Definition",Space,Str "Lists"]
, Para [Str "Tight",Space,Str "using",Space,Str "spaces:"]

View file

@ -281,6 +281,10 @@ Autonumbering:
#. More.
#. Nested.
Should not be a list item:
M.A. 2007
* * * * *
# Definition Lists

View file

@ -399,6 +399,10 @@ Autonumbering:
\item Nested.
\stopltxenum
\stopltxenum
Should not be a list item:
M.A. 2007
\thinrule
\section{Definition Lists}

View file

@ -642,6 +642,12 @@ These should not be escaped: \$ \\ \&gt; \[ \{
</orderedlist>
</listitem>
</orderedlist>
<para>
Should not be a list item:
</para>
<para>
M.A. 2007
</para>
</section>
</section>
<section>

View file

@ -449,6 +449,10 @@ These should not be escaped: \$ \\ \&gt; \[ \{
></ol
></li
></ol
><p
>Should not be a list item:</p
><p
>M.A. 2007</p
><hr
/><h1 id="definition-lists"
>Definition Lists</h1

View file

@ -345,6 +345,10 @@ Autonumbering:
\item Nested.
\end{enumerate}
\end{enumerate}
Should not be a list item:
M.A. 2007
\begin{center}\rule{3in}{0.4pt}\end{center}
\section{Definition Lists}

View file

@ -321,6 +321,10 @@ More\.
.IP "1." 3
Nested\.
.RE
.PP
Should not be a list item:
.PP
M\.A\. 2007
.PP
* * * * *
.SH Definition Lists

View file

@ -284,6 +284,10 @@ Autonumbering:
1. Nested.
Should not be a list item:
M.A. 2007
* * * * *

View file

@ -178,6 +178,8 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] ["John MacFarlane
, OrderedList (1,DefaultStyle,DefaultDelim)
[ [ Plain [Str "Nested",Str "."] ]
] ] ]
, Para [Str "Should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "list",Space,Str "item:"]
, Para [Str "M",Str ".",Str "A",Str ".",Space,Str "2007"]
, HorizontalRule
, Header 1 [Str "Definition",Space,Str "Lists"]
, Para [Str "Tight",Space,Str "using",Space,Str "spaces:"]

View file

@ -348,6 +348,10 @@ Autonumbering:
#. Nested.
Should not be a list item:
M.A. 2007
--------------
Definition Lists

View file

@ -157,6 +157,8 @@ These should not be escaped: \\$ \\\\ \\> \\[ \\\{\par}
{\pard \ql \f0 \sa0 \li360 \fi-360 1.\tx360\tab Autonumber.\par}
{\pard \ql \f0 \sa0 \li360 \fi-360 2.\tx360\tab More.\par}
{\pard \ql \f0 \sa0 \li720 \fi-360 a.\tx360\tab Nested.\sa180\sa180\par}
{\pard \ql \f0 \sa180 \li0 \fi0 Should not be a list item:\par}
{\pard \ql \f0 \sa180 \li0 \fi0 M.A. 2007\par}
{\pard \qc \f0 \sa180 \li0 \fi0 \emdash\emdash\emdash\emdash\emdash\par}
{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs36 Definition Lists\par}
{\pard \ql \f0 \sa180 \li0 \fi0 Tight using spaces:\par}