git.iko.soy/typeable/pandoc
on master help sign in
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

commitf11360f50e9104bb6ac203c14ec7f02c5b844a96 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateThu 23 Aug 2007, 04:25 (19 years ago) parente29e5c5
13 files changed+56−30
README+27−24 src/Text/Pandoc/Readers/Markdown.hs+9−6 tests/testsuite.native+1 tests/testsuite.txt+2 tests/writer.context+2 tests/writer.docbook+3 tests/writer.html+2 tests/writer.latex+2 tests/writer.man+2 tests/writer.markdown+2 tests/writer.native+1 tests/writer.rst+2 tests/writer.rtf+1
README+27−24
@@ -452,11 +452,31 @@ Unlike standard markdown, Pandoc allows ordered list items to be marked
452452with uppercase and lowercase letters and roman numerals, in addition to
453453arabic numerals. (This behavior can be turned off using the `--strict`
454454option.) List markers may be enclosed in parentheses or followed by a
455−single right-parentheses or period. Pandoc also pays attention to the
456−type of list marker used, and to the starting number, and both of these
457−are preserved where possible in the output format. Thus, the following
458−yields a list with numbers followed by a single parenthesis, starting
459−with 9, and a sublist with lowercase roman numerals:
455+single right-parentheses or period. They must be separated from the
456+text that follows by at least one space, and, if the list marker is a
457+capital letter with a period, by at least two spaces.[^2]
458+
459+[^2]: The point of this rule is to ensure that normal paragraphs
460+ starting with people's initials, like
461+
462+ B. Russell was an English philosopher.
463+
464+ do not get treated as list items.
465+
466+ This rule will not prevent
467+
468+ (C) 2007 Joe Smith
469+
470+ from being interpreted as a list item. In this case, a backslash
471+ escape can be used:
472+
473+ (C\) 2007 Joe Smith
474+
475+Pandoc also pays attention to the type of list marker used, and to the
476+starting number, and both of these are preserved where possible in the
477+output format. Thus, the following yields a list with numbers followed
478+by a single parenthesis, starting with 9, and a sublist with lowercase
479+roman numerals:
460480
461481 9) Ninth
462482 10) Tenth
@@ -491,27 +511,10 @@ gets treated as if it were
491511
492512 1. One
493513 2. Two
494− A. Sub
495− B. Sub
514+ A. Sub
515+ B. Sub
496516 3. Three
497517
498−Note that a list beginning with a single letter will be interpreted as
499−an alphabetic list. So you are out of luck if you want a roman-numbered
500−list starting with 100 (C).
501−
502−Note also that a paragraph starting with a capital letter and a period
503−(for example, an initial) or a capital letter in parentheses
504−(for example, `(C)`) will be interpreted as a list:
505−
506− B. Russell was an English philosopher.
507−
508− (C) 2007 Joe Smith
509−
510−To avoid this, use backslash escapes:
511−
512− B\. Russell was an English philosopher.
513−
514− \(C) 2007 Joe Smith
515518
516519Definition lists
517520----------------
src/Text/Pandoc/Readers/Markdown.hs+9−6
@@ -327,12 +327,15 @@ orderedListStart style delim = try $ do
327327 optional newline -- if preceded by a Plain block in a list context
328328 nonindentSpaces
329329 state <- getState
330− if stateStrict state
331− then do many1 digit
332− char '.'
333− return 1
334− else orderedListMarker style delim
335− spaceChar
330+ num <- if stateStrict state
331+ then do many1 digit
332+ char '.'
333+ return 1
334+ else orderedListMarker style delim
335+ if delim == Period && (style == UpperAlpha || (style == UpperRoman &&
336+ num `elem` [1, 5, 10, 50, 100, 500, 1000]))
337+ then char '\t' <|> (spaceChar >> spaceChar)
338+ else spaceChar
336339 skipSpaces
337340
338341-- parse a line of a list item (start = parser for beginning of list item)
tests/testsuite.native+1
@@ -180,6 +180,7 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] ["John MacFarlane
180180 ] ] ]
181181, Para [Str "Should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "list",Space,Str "item:"]
182182, Para [Str "M",Str ".",Str "A",Str ".",Space,Str "2007"]
183+, Para [Str "B",Str ".",Space,Str "Williams"]
183184, HorizontalRule
184185, Header 1 [Str "Definition",Space,Str "Lists"]
185186, Para [Str "Tight",Space,Str "using",Space,Str "spaces:"]
tests/testsuite.txt+2
@@ -285,6 +285,8 @@ Should not be a list item:
285285
286286M.A. 2007
287287
288+B. Williams
289+
288290 * * * * *
289291
290292# Definition Lists
tests/writer.context+2
@@ -403,6 +403,8 @@ Should not be a list item:
403403
404404M.A. 2007
405405
406+B. Williams
407+
406408\thinrule
407409
408410\section{Definition Lists}
tests/writer.docbook+3
@@ -648,6 +648,9 @@ These should not be escaped: \$ \\ \&gt; \[ \{
648648 <para>
649649 M.A. 2007
650650 </para>
651+ <para>
652+ B. Williams
653+ </para>
651654 </section>
652655 </section>
653656 <section>
tests/writer.html+2
@@ -453,6 +453,8 @@ These should not be escaped: \$ \\ \&gt; \[ \{
453453 >Should not be a list item:</p
454454 ><p
455455 >M.A. 2007</p
456+ ><p
457+ >B. Williams</p
456458 ><hr
457459 /><h1 id="definition-lists"
458460 >Definition Lists</h1
tests/writer.latex+2
@@ -349,6 +349,8 @@ Should not be a list item:
349349
350350M.A. 2007
351351
352+B. Williams
353+
352354\begin{center}\rule{3in}{0.4pt}\end{center}
353355
354356\section{Definition Lists}
tests/writer.man+2
@@ -325,6 +325,8 @@ Nested\.
325325Should not be a list item:
326326.PP
327327M\.A\. 2007
328+.PP
329+B\. Williams
328330.PP
329331 * * * * *
330332.SH Definition Lists
tests/writer.markdown+2
@@ -288,6 +288,8 @@ Should not be a list item:
288288
289289M.A. 2007
290290
291+B. Williams
292+
291293
292294* * * * *
293295
tests/writer.native+1
@@ -180,6 +180,7 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] ["John MacFarlane
180180 ] ] ]
181181, Para [Str "Should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "list",Space,Str "item:"]
182182, Para [Str "M",Str ".",Str "A",Str ".",Space,Str "2007"]
183+, Para [Str "B",Str ".",Space,Str "Williams"]
183184, HorizontalRule
184185, Header 1 [Str "Definition",Space,Str "Lists"]
185186, Para [Str "Tight",Space,Str "using",Space,Str "spaces:"]
tests/writer.rst+2
@@ -352,6 +352,8 @@ Should not be a list item:
352352
353353M.A. 2007
354354
355+B. Williams
356+
355357--------------
356358
357359Definition Lists
tests/writer.rtf+1
@@ -159,6 +159,7 @@ These should not be escaped: \\$ \\\\ \\> \\[ \\\{\par}
159159{\pard \ql \f0 \sa0 \li720 \fi-360 a.\tx360\tab Nested.\sa180\sa180\par}
160160{\pard \ql \f0 \sa180 \li0 \fi0 Should not be a list item:\par}
161161{\pard \ql \f0 \sa180 \li0 \fi0 M.A. 2007\par}
162+{\pard \ql \f0 \sa180 \li0 \fi0 B. Williams\par}
162163{\pard \qc \f0 \sa180 \li0 \fi0 \emdash\emdash\emdash\emdash\emdash\par}
163164{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs36 Definition Lists\par}
164165{\pard \ql \f0 \sa180 \li0 \fi0 Tight using spaces:\par}