aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-08-18 15:26:29 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-08-18 15:26:29 +0000
commite48f046aa024fea9f806368796eaaaed1f09ceaf (patch)
tree368f96d85012242b4918190b6fd20e3c32fd9228
parentfcda8d191b7683779fdce93beb9814960e749df9 (diff)
downloadpandoc-e48f046aa024fea9f806368796eaaaed1f09ceaf.tar.gz
+ 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
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs5
-rw-r--r--src/Text/Pandoc/Readers/RST.hs5
-rw-r--r--tests/testsuite.native2
-rw-r--r--tests/testsuite.txt4
-rw-r--r--tests/writer.context4
-rw-r--r--tests/writer.docbook6
-rw-r--r--tests/writer.html4
-rw-r--r--tests/writer.latex4
-rw-r--r--tests/writer.man4
-rw-r--r--tests/writer.markdown4
-rw-r--r--tests/writer.native2
-rw-r--r--tests/writer.rst4
-rw-r--r--tests/writer.rtf2
13 files changed, 46 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index 6ee8df7b6..abf8061e0 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -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)
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs
index ce8fedf02..878c1355c 100644
--- a/src/Text/Pandoc/Readers/RST.hs
+++ b/src/Text/Pandoc/Readers/RST.hs
@@ -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
diff --git a/tests/testsuite.native b/tests/testsuite.native
index 11719eb16..9950341c4 100644
--- a/tests/testsuite.native
+++ b/tests/testsuite.native
@@ -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:"]
diff --git a/tests/testsuite.txt b/tests/testsuite.txt
index 31b5c3bed..f8d9221b9 100644
--- a/tests/testsuite.txt
+++ b/tests/testsuite.txt
@@ -281,6 +281,10 @@ Autonumbering:
#. More.
#. Nested.
+Should not be a list item:
+
+M.A. 2007
+
* * * * *
# Definition Lists
diff --git a/tests/writer.context b/tests/writer.context
index fe7c58851..c0b633117 100644
--- a/tests/writer.context
+++ b/tests/writer.context
@@ -399,6 +399,10 @@ Autonumbering:
\item Nested.
\stopltxenum
\stopltxenum
+Should not be a list item:
+
+M.A. 2007
+
\thinrule
\section{Definition Lists}
diff --git a/tests/writer.docbook b/tests/writer.docbook
index 390c9f4fe..7b3f39f34 100644
--- a/tests/writer.docbook
+++ b/tests/writer.docbook
@@ -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>
diff --git a/tests/writer.html b/tests/writer.html
index 6c3637315..46a95cde7 100644
--- a/tests/writer.html
+++ b/tests/writer.html
@@ -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
diff --git a/tests/writer.latex b/tests/writer.latex
index fb771182f..ec35ae30d 100644
--- a/tests/writer.latex
+++ b/tests/writer.latex
@@ -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}
diff --git a/tests/writer.man b/tests/writer.man
index 05d766108..5b8d97094 100644
--- a/tests/writer.man
+++ b/tests/writer.man
@@ -322,6 +322,10 @@ More\.
Nested\.
.RE
.PP
+Should not be a list item:
+.PP
+M\.A\. 2007
+.PP
* * * * *
.SH Definition Lists
.PP
diff --git a/tests/writer.markdown b/tests/writer.markdown
index 298e8e825..42f63abca 100644
--- a/tests/writer.markdown
+++ b/tests/writer.markdown
@@ -284,6 +284,10 @@ Autonumbering:
1. Nested.
+Should not be a list item:
+
+M.A. 2007
+
* * * * *
diff --git a/tests/writer.native b/tests/writer.native
index 11719eb16..9950341c4 100644
--- a/tests/writer.native
+++ b/tests/writer.native
@@ -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:"]
diff --git a/tests/writer.rst b/tests/writer.rst
index 0f059761c..188df8c7b 100644
--- a/tests/writer.rst
+++ b/tests/writer.rst
@@ -348,6 +348,10 @@ Autonumbering:
#. Nested.
+Should not be a list item:
+
+M.A. 2007
+
--------------
Definition Lists
diff --git a/tests/writer.rtf b/tests/writer.rtf
index 6ff422603..35607ebba 100644
--- a/tests/writer.rtf
+++ b/tests/writer.rtf
@@ -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}