Added new rule for enhanced markdown ordered lists: if the list marker

is a capital letter followed by a period (including a single-letter
capital roman numeral), then it must be followed by at least two spaces.
The point of this is to avoid accidentally treating people's initials as
list markers: a paragraph may begin:

    B. Russell was an English philosopher.

and this shouldn't be treated as a list.

Modified Markdown reader and README documentation.
Added a test case.


git-svn-id: https://pandoc.googlecode.com/svn/trunk@880 788f1e2b-df1e-0410-8736-df70ead52e1b
This commit is contained in:
fiddlosopher 2007-08-23 04:25:09 +00:00
parent e29e5c5944
commit f11360f50e
13 changed files with 56 additions and 30 deletions

51
README
View file

@ -452,11 +452,31 @@ Unlike standard markdown, Pandoc allows ordered list items to be marked
with uppercase and lowercase letters and roman numerals, in addition to
arabic numerals. (This behavior can be turned off using the `--strict`
option.) List markers may be enclosed in parentheses or followed by a
single right-parentheses or period. Pandoc also pays attention to the
type of list marker used, and to the starting number, and both of these
are preserved where possible in the output format. Thus, the following
yields a list with numbers followed by a single parenthesis, starting
with 9, and a sublist with lowercase roman numerals:
single right-parentheses or period. They must be separated from the
text that follows by at least one space, and, if the list marker is a
capital letter with a period, by at least two spaces.[^2]
[^2]: The point of this rule is to ensure that normal paragraphs
starting with people's initials, like
B. Russell was an English philosopher.
do not get treated as list items.
This rule will not prevent
(C) 2007 Joe Smith
from being interpreted as a list item. In this case, a backslash
escape can be used:
(C\) 2007 Joe Smith
Pandoc also pays attention to the type of list marker used, and to the
starting number, and both of these are preserved where possible in the
output format. Thus, the following yields a list with numbers followed
by a single parenthesis, starting with 9, and a sublist with lowercase
roman numerals:
9) Ninth
10) Tenth
@ -491,27 +511,10 @@ gets treated as if it were
1. One
2. Two
A. Sub
B. Sub
A. Sub
B. Sub
3. Three
Note that a list beginning with a single letter will be interpreted as
an alphabetic list. So you are out of luck if you want a roman-numbered
list starting with 100 (C).
Note also that a paragraph starting with a capital letter and a period
(for example, an initial) or a capital letter in parentheses
(for example, `(C)`) will be interpreted as a list:
B. Russell was an English philosopher.
(C) 2007 Joe Smith
To avoid this, use backslash escapes:
B\. Russell was an English philosopher.
\(C) 2007 Joe Smith
Definition lists
----------------

View file

@ -327,12 +327,15 @@ orderedListStart style delim = try $ do
optional newline -- if preceded by a Plain block in a list context
nonindentSpaces
state <- getState
if stateStrict state
then do many1 digit
char '.'
return 1
else orderedListMarker style delim
spaceChar
num <- if stateStrict state
then do many1 digit
char '.'
return 1
else orderedListMarker style delim
if delim == Period && (style == UpperAlpha || (style == UpperRoman &&
num `elem` [1, 5, 10, 50, 100, 500, 1000]))
then char '\t' <|> (spaceChar >> spaceChar)
else spaceChar
skipSpaces
-- parse a line of a list item (start = parser for beginning of list item)

View file

@ -180,6 +180,7 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] ["John MacFarlane
] ] ]
, 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"]
, Para [Str "B",Str ".",Space,Str "Williams"]
, HorizontalRule
, Header 1 [Str "Definition",Space,Str "Lists"]
, Para [Str "Tight",Space,Str "using",Space,Str "spaces:"]

View file

@ -285,6 +285,8 @@ Should not be a list item:
M.A. 2007
B. Williams
* * * * *
# Definition Lists

View file

@ -403,6 +403,8 @@ Should not be a list item:
M.A. 2007
B. Williams
\thinrule
\section{Definition Lists}

View file

@ -648,6 +648,9 @@ These should not be escaped: \$ \\ \&gt; \[ \{
<para>
M.A. 2007
</para>
<para>
B. Williams
</para>
</section>
</section>
<section>

View file

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

View file

@ -349,6 +349,8 @@ Should not be a list item:
M.A. 2007
B. Williams
\begin{center}\rule{3in}{0.4pt}\end{center}
\section{Definition Lists}

View file

@ -325,6 +325,8 @@ Nested\.
Should not be a list item:
.PP
M\.A\. 2007
.PP
B\. Williams
.PP
* * * * *
.SH Definition Lists

View file

@ -288,6 +288,8 @@ Should not be a list item:
M.A. 2007
B. Williams
* * * * *

View file

@ -180,6 +180,7 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] ["John MacFarlane
] ] ]
, 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"]
, Para [Str "B",Str ".",Space,Str "Williams"]
, HorizontalRule
, Header 1 [Str "Definition",Space,Str "Lists"]
, Para [Str "Tight",Space,Str "using",Space,Str "spaces:"]

View file

@ -352,6 +352,8 @@ Should not be a list item:
M.A. 2007
B. Williams
--------------
Definition Lists

View file

@ -159,6 +159,7 @@ These should not be escaped: \\$ \\\\ \\> \\[ \\\{\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 \ql \f0 \sa180 \li0 \fi0 B. Williams\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}