git.iko.soy/typeable/pandoc
on master help sign in
Major change in the way ordered lists are handled:

+ The changes are documented in README, under Lists. + The OrderedList block element now stores information about list number style, list number delimiter, and starting number. + The readers parse this information, when possible. + The writers use this information to style ordered lists. + Test suites have been changed accordingly. Motivation: It's often useful to start lists with numbers other than 1, and to have control over the style of the list. Added to Text.Pandoc.Shared: + camelCaseToHyphenated + toRomanNumeral + anyOrderedListMarker + orderedListMarker + orderedListMarkers Added to Text.Pandoc.ParserCombinators: + charsInBalanced' + withHorizDisplacement + romanNumeral RST writer: + Force blank line before lists, so that sublists will be handled correctly. LaTeX reader: + Fixed bug in parsing of footnotes containing multiple paragraphs, introduced by use of charsInBalanced. Fix: use charsInBalanced' instead. LaTeX header: + use mathletters option in ucs package, so that basic unicode Greek letters will work properly. git-svn-id: https://pandoc.googlecode.com/svn/trunk@834 788f1e2b-df1e-0410-8736-df70ead52e1b

commite814a3f6d23f640b1aed5b7cb949459d514a3e33 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateWed 8 Aug 2007, 02:43 (19 years ago) parent22a6538
36 files changed+1359−385
README+70−39 src/Text/Pandoc/Definition.hs+19−2 src/Text/Pandoc/ParserCombinators.hs+60−2 src/Text/Pandoc/Readers/HTML.hs+17−2 src/Text/Pandoc/Readers/LaTeX.hs+22−8 src/Text/Pandoc/Readers/Markdown.hs+25−16 src/Text/Pandoc/Readers/RST.hs+11−44 src/Text/Pandoc/Shared.hs+160−6 src/Text/Pandoc/Writers/ConTeXt.hs+18−3 src/Text/Pandoc/Writers/Docbook.hs+15−2 src/Text/Pandoc/Writers/HTML.hs+51−27 src/Text/Pandoc/Writers/LaTeX.hs+20−4 src/Text/Pandoc/Writers/Man.hs+16−17 src/Text/Pandoc/Writers/Markdown.hs+17−14 src/Text/Pandoc/Writers/RST.hs+33−23 src/Text/Pandoc/Writers/RTF.hs+9−7 src/headers/LaTeXHeader+1−1 tests/html-reader.html+56 tests/html-reader.native+38−9 tests/rst-reader.native+35−7 tests/rst-reader.rst+31 tests/s5.basic.html+1−1 tests/s5.fancy.html+1−1 tests/s5.inserts.html+1−1 tests/tables.rst−1 tests/testsuite.native+38−10 tests/testsuite.txt+26 tests/writer.context+86−46 tests/writer.docbook+105−10 tests/writer.html+73−12 tests/writer.latex+56−11 tests/writer.man+71−26 tests/writer.markdown+31 tests/writer.native+38−10 tests/writer.rst+91−23 tests/writer.rtf+17
README+70−39
@@ -437,45 +437,76 @@ cases" involving lists. Consider this source:
437437
438438 3. Third
439439
440−Pandoc transforms this into a "compact list" (with no `<p>` tags
441−around "First", "Second", or "Third"), while markdown puts `<p>`
442−tags around "Second" and "Third" (but not "First"), because of
443−the blank space around "Third". Pandoc follows a simple rule:
444−if the text is followed by a blank line, it is treated as a
445−paragraph. Since "Second" is followed by a list, and not a blank
446−line, it isn't treated as a paragraph. The fact that the list
447−is followed by a blank line is irrelevant. (Note: Pandoc works
448−this way even when the `--strict` option is specified. This
449−behavior is consistent with the official markdown syntax
450−description, even though it is different from that of `Markdown.pl`.)
451−
452−Unlike standard markdown, Pandoc allows ordered list items to be
453−marked with single lowercase letters (from 'a' to 'n'), instead of
454−numbers. So, for example, this source yields a nested ordered list:
455−
456− 1. First
457− 2. Second
458− a. Fee
459− b. Fie
460− 3. Third
461−
462−The letters may be followed by either '.' or ')':
463−
464− 1. First
465− 2. Second
466− a) Fee
467− b) Fie
468− 3. Third
469−
470−Note that Pandoc pays no attention to the *type* of ordered list
471−item marker used. Thus, the following is treated just the same as
472−the example above:
473−
474− a) First
475− 1. Second
476− 2. Fee
477− b) Fie
478− c. Third
440+Pandoc transforms this into a "compact list" (with no `<p>` tags around
441+"First", "Second", or "Third"), while markdown puts `<p>` tags around
442+"Second" and "Third" (but not "First"), because of the blank space
443+around "Third". Pandoc follows a simple rule: if the text is followed by
444+a blank line, it is treated as a paragraph. Since "Second" is followed
445+by a list, and not a blank line, it isn't treated as a paragraph. The
446+fact that the list is followed by a blank line is irrelevant. (Note:
447+Pandoc works this way even when the `--strict` option is specified. This
448+behavior is consistent with the official markdown syntax description,
449+even though it is different from that of `Markdown.pl`.)
450+
451+Unlike standard markdown, Pandoc allows ordered list items to be marked
452+with uppercase and lowercase letters and roman numerals, in addition to
453+arabic numerals. (This behavior can be turned off using the `--strict`
454+option.) 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:
460+
461+ 9) Ninth
462+ 10) Tenth
463+ 11) Eleventh
464+ i. subone
465+ ii. subtwo
466+ iii. subthree
467+
468+Note that Pandoc pays attention only to the *starting* number in a list.
469+So, the following yields a list numbered sequentially starting from 2:
470+
471+ (2) Two
472+ (5) Three
473+ (2) Four
474+
475+If default list markers are desired, use '`#.`':
476+
477+ #. one
478+ #. two
479+ #. three
480+
481+If you change list style in mid-list, Pandoc will notice and assume you
482+are starting a sublist. So,
483+
484+ 1. One
485+ 2. Two
486+ A. Sub
487+ B. Sub
488+ 3. Three
489+
490+gets treated as if it were
491+
492+ 1. One
493+ 2. Two
494+ A. Sub
495+ B. Sub
496+ 3. Three
497+
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) will be interpreted as a list:
504+
505+ B. Russell was an English philosopher.
506+
507+To avoid this, use backslash escapes:
508+
509+ B\. Russell was an English philosopher.
479510
480511Definition lists
481512----------------
src/Text/Pandoc/Definition.hs+19−2
@@ -45,6 +45,23 @@ data Alignment = AlignLeft
4545 | AlignCenter
4646 | AlignDefault deriving (Eq, Show, Read)
4747
48+-- | List attributes.
49+type ListAttributes = (Int, ListNumberStyle, ListNumberDelim)
50+
51+-- | Style of list numbers.
52+data ListNumberStyle = DefaultStyle
53+ | Decimal
54+ | LowerRoman
55+ | UpperRoman
56+ | LowerAlpha
57+ | UpperAlpha deriving (Eq, Show, Read)
58+
59+-- | Delimiter of list numbers.
60+data ListNumberDelim = DefaultDelim
61+ | Period
62+ | OneParen
63+ | TwoParens deriving (Eq, Show, Read)
64+
4865-- | Block element.
4966data Block
5067 = Plain [Inline] -- ^ Plain text, not a paragraph
@@ -53,8 +70,8 @@ data Block
5370 | CodeBlock String -- ^ Code block (literal)
5471 | RawHtml String -- ^ Raw HTML block (literal)
5572 | BlockQuote [Block] -- ^ Block quote (list of blocks)
56− | OrderedList [[Block]] -- ^ Ordered list (list of items, each
57− -- a list of blocks)
73+ | OrderedList ListAttributes [[Block]] -- ^ Ordered list (attributes,
74+ -- and a list of items, each a list of blocks)
5875 | BulletList [[Block]] -- ^ Bullet list (list of items, each
5976 -- a list of blocks)
6077 | DefinitionList [([Inline],[Block])] -- ^ Definition list
src/Text/Pandoc/ParserCombinators.hs+60−2
@@ -40,7 +40,10 @@ module Text.Pandoc.ParserCombinators (
4040 stringAnyCase,
4141 parseFromString,
4242 lineClump,
43− charsInBalanced
43+ charsInBalanced,
44+ charsInBalanced',
45+ romanNumeral,
46+ withHorizDisplacement
4447 ) where
4548import Text.ParserCombinators.Parsec
4649import Data.Char ( toUpper, toLower )
@@ -127,7 +130,8 @@ lineClump = do
127130-- and a close character, including text between balanced
128131-- pairs of open and close. For example,
129132-- @charsInBalanced '(' ')'@ will parse "(hello (there))"
130−-- and return "hello (there)".
133+-- and return "hello (there)". Stop if a blank line is
134+-- encountered.
131135charsInBalanced :: Char -> Char -> GenParser Char st String
132136charsInBalanced open close = try $ do
133137 char open
@@ -138,3 +142,57 @@ charsInBalanced open close = try $ do
138142 (char close)
139143 return $ concat raw
140144
145+-- | Like charsInBalanced, but allow blank lines in the content.
146+charsInBalanced' :: Char -> Char -> GenParser Char st String
147+charsInBalanced' open close = try $ do
148+ char open
149+ raw <- manyTill ( (do res <- charsInBalanced open close
150+ return $ [open] ++ res ++ [close])
151+ <|> count 1 anyChar)
152+ (char close)
153+ return $ concat raw
154+
155+-- | Parses a roman numeral (uppercase or lowercase), returns number.
156+romanNumeral :: Bool -> -- ^ Uppercase if true
157+ GenParser Char st Int
158+romanNumeral upper = try $ do
159+ let char' c = char (if upper then toUpper c else c)
160+ let one = char' 'i'
161+ let five = char' 'v'
162+ let ten = char' 'x'
163+ let fifty = char' 'l'
164+ let hundred = char' 'c'
165+ let fivehundred = char' 'd'
166+ let thousand = char' 'm'
167+ thousands <- many thousand >>= (return . (1000 *) . length)
168+ ninehundreds <- option 0 $ try $ hundred >> thousand >> return 900
169+ fivehundreds <- many fivehundred >>= (return . (500 *) . length)
170+ fourhundreds <- option 0 $ try $ hundred >> fivehundred >> return 400
171+ hundreds <- many hundred >>= (return . (100 *) . length)
172+ nineties <- option 0 $ try $ ten >> hundred >> return 90
173+ fifties <- many fifty >>= (return . (50 *) . length)
174+ forties <- option 0 $ try $ ten >> fifty >> return 40
175+ tens <- many ten >>= (return . (10 *) . length)
176+ nines <- option 0 $ try $ one >> ten >> return 9
177+ fives <- many five >>= (return . (5*) . length)
178+ fours <- option 0 $ try $ one >> five >> return 4
179+ ones <- many one >>= (return . length)
180+ let total = thousands + ninehundreds + fivehundreds + fourhundreds +
181+ hundreds + nineties + fifties + forties + tens + nines +
182+ fives + fours + ones
183+ if total == 0
184+ then fail "not a roman numeral"
185+ else return total
186+
187+-- | Applies a parser, returns tuple of its results and its horizontal
188+-- displacement (the difference between the source column at the end
189+-- and the source column at the beginning). Vertical displacement
190+-- (source row) is ignored.
191+withHorizDisplacement :: GenParser Char st a -- ^ Parser to apply
192+ -> GenParser Char st (a, Int) -- ^ (result, displacement)
193+withHorizDisplacement parser = do
194+ pos1 <- getPosition
195+ result <- parser
196+ pos2 <- getPosition
197+ return (result, sourceColumn pos2 - sourceColumn pos1)
198+
src/Text/Pandoc/Readers/HTML.hs+17−2
@@ -354,11 +354,26 @@ blockQuote = try (do
354354list = choice [ bulletList, orderedList, definitionList ] <?> "list"
355355
356356orderedList = try $ do
357− htmlTag "ol"
357+ (_, attribs) <- htmlTag "ol"
358+ (start, style) <- option (1, DefaultStyle) $
359+ do failIfStrict
360+ let sta = fromMaybe "1" $
361+ lookup "start" attribs
362+ let sty = fromMaybe (fromMaybe "" $
363+ lookup "style" attribs) $
364+ lookup "class" attribs
365+ let sty' = case sty of
366+ "lower-roman" -> LowerRoman
367+ "upper-roman" -> UpperRoman
368+ "lower-alpha" -> LowerAlpha
369+ "upper-alpha" -> UpperAlpha
370+ "decimal" -> Decimal
371+ _ -> DefaultStyle
372+ return (read sta, sty')
358373 spaces
359374 items <- sepEndBy1 (blocksIn "li") spaces
360375 htmlEndTag "ol"
361− return (OrderedList items)
376+ return (OrderedList (start, style, DefaultDelim) items)
362377
363378bulletList = try $ do
364379 htmlTag "ul"
src/Text/Pandoc/Readers/LaTeX.hs+22−8
@@ -59,12 +59,8 @@ specialChars = "\\$%&^&_~#{}\n \t|<>'\"-"
5959
6060-- | Returns text between brackets and its matching pair.
6161bracketedText openB closeB = try (do
62− char openB
63− result <- many (choice [ oneOfStrings [ ['\\', openB], ['\\', closeB] ],
64− count 1 (noneOf [openB, closeB]),
65− bracketedText openB closeB ])
66− char closeB
67− return ([openB] ++ (concat result) ++ [closeB]))
62+ result <- charsInBalanced' openB closeB
63+ return ([openB] ++ result ++ [closeB]))
6864
6965-- | Returns an option or argument of a LaTeX command.
7066optOrArg = choice [ (bracketedText '{' '}'), (bracketedText '[' ']') ]
@@ -255,12 +251,30 @@ listItem = try $ do
255251 return (opt, blocks)
256252
257253orderedList = try $ do
258− begin "enumerate"
254+ string "\\begin{enumerate}"
255+ (_, style, delim) <- option (1, DefaultStyle, DefaultDelim) $
256+ try $ do failIfStrict
257+ char '['
258+ res <- anyOrderedListMarker
259+ char ']'
260+ return res
259261 spaces
262+ option "" $ try $ do string "\\setlength{\\itemindent}"
263+ char '{'
264+ manyTill anyChar (char '}')
265+ spaces
266+ start <- option 1 $ try $ do failIfStrict
267+ string "\\setcounter{enum"
268+ many1 (char 'i')
269+ string "}{"
270+ num <- many1 digit
271+ char '}'
272+ spaces
273+ return $ (read num) + 1
260274 items <- many listItem
261275 end "enumerate"
262276 spaces
263− return (OrderedList $ map snd items)
277+ return $ OrderedList (start, style, delim) $ map snd items
264278
265279bulletList = try $ do
266280 begin "itemize"
src/Text/Pandoc/Readers/Markdown.hs+25−16
@@ -243,6 +243,8 @@ header = choice [ setextHeader, atxHeader ] <?> "header"
243243
244244atxHeader = try (do
245245 lead <- many1 (char '#')
246+ notFollowedBy (char '.') -- this would be a list
247+ notFollowedBy (char ')')
246248 skipSpaces
247249 txt <- manyTill inline atxClosing
248250 return (Header (length lead) (normalizeSpaces txt)))
@@ -354,27 +356,33 @@ blockQuote = do
354356
355357list = choice [ bulletList, orderedList, definitionList ] <?> "list"
356358
357−bulletListStart = try (do
359+bulletListStart = try $ do
358360 option ' ' newline -- if preceded by a Plain block in a list context
359361 nonindentSpaces
360362 notFollowedBy' hrule -- because hrules start out just like lists
361363 oneOf bulletListMarkers
362364 spaceChar
363− skipSpaces)
364−
365−standardOrderedListStart = try (do
366− many1 digit
367− char '.')
365+ skipSpaces
368366
369−extendedOrderedListStart = try (do
370− failIfStrict
371− oneOf ['a'..'n']
372− oneOf ".)")
367+anyOrderedListStart = try $ do
368+ option ' ' newline -- if preceded by a Plain block in a list context
369+ nonindentSpaces
370+ state <- getState
371+ if stateStrict state
372+ then do many1 digit
373+ char '.'
374+ return (1, DefaultStyle, DefaultDelim)
375+ else anyOrderedListMarker
373376
374−orderedListStart = try $ do
377+orderedListStart style delim = try $ do
375378 option ' ' newline -- if preceded by a Plain block in a list context
376379 nonindentSpaces
377− standardOrderedListStart <|> extendedOrderedListStart
380+ state <- getState
381+ if stateStrict state
382+ then do many1 digit
383+ char '.'
384+ return 1
385+ else orderedListMarker style delim
378386 oneOf spaceChars
379387 skipSpaces
380388
@@ -385,7 +393,7 @@ listLine start = try (do
385393 notFollowedBy' (do
386394 indentSpaces
387395 many (spaceChar)
388− choice [bulletListStart, orderedListStart])
396+ choice [bulletListStart, anyOrderedListStart >> return ()])
389397 line <- manyTill anyChar newline
390398 return (line ++ "\n"))
391399
@@ -431,9 +439,10 @@ listItem start = try (do
431439 return contents)
432440
433441orderedList = try (do
434− items <- many1 (listItem orderedListStart)
442+ (start, style, delim) <- lookAhead anyOrderedListStart
443+ items <- many1 (listItem (orderedListStart style delim))
435444 let items' = compactify items
436− return (OrderedList items'))
445+ return (OrderedList (start, style, delim) items'))
437446
438447bulletList = try (do
439448 items <- many1 (listItem bulletListStart)
@@ -906,7 +915,7 @@ endline = try (do
906915 else return ()
907916 -- parse potential list-starts differently if in a list:
908917 if (stateParserContext st) == ListItemState
909− then notFollowedBy' (orderedListStart <|> bulletListStart)
918+ then notFollowedBy' $ choice [bulletListStart, anyOrderedListStart >> return ()]
910919 else return ()
911920 return Space)
912921
src/Text/Pandoc/Readers/RST.hs+11−44
@@ -379,46 +379,11 @@ bulletListStart = try (do
379379 let len = length (marker:white)
380380 return len)
381381
382−withPeriodSuffix parser = try (do
383− a <- parser
384− b <- char '.'
385− return (a ++ [b]))
386−
387−withParentheses parser = try (do
388− a <- char '('
389− b <- parser
390− c <- char ')'
391− return ([a] ++ b ++ [c]))
392−
393−withRightParen parser = try (do
394− a <- parser
395− b <- char ')'
396− return (a ++ [b]))
397−
398−upcaseWord = map toUpper
399−
400−romanNumeral = do
401− let lowerNumerals = ["i", "ii", "iii", "iiii", "iv", "v", "vi",
402− "vii", "viii", "ix", "x", "xi", "xii", "xiii",
403− "xiv", "xv", "xvi", "xvii", "xviii", "xix", "xx",
404− "xxi", "xxii", "xxiii", "xxiv" ]
405− let upperNumerals = map upcaseWord lowerNumerals
406− result <- choice $ map string (lowerNumerals ++ upperNumerals)
407− return result
408−
409−orderedListEnumerator = choice [ many1 digit,
410− count 1 (char '#'),
411− count 1 letter,
412− romanNumeral ]
413−
414382-- parses ordered list start and returns its length (inc following whitespace)
415−orderedListStart = try (do
416− marker <- choice [ withPeriodSuffix orderedListEnumerator,
417− withParentheses orderedListEnumerator,
418− withRightParen orderedListEnumerator ]
383+orderedListStart style delim = try $ do
384+ (_, markerLen) <- withHorizDisplacement (orderedListMarker style delim)
419385 white <- many1 spaceChar
420− let len = length (marker ++ white)
421− return len)
386+ return $ markerLen + length white
422387
423388-- parse a line of a list item
424389listLine markerLength = try (do
@@ -437,11 +402,11 @@ indentWith num = do
437402 (try (do {char '\t'; count (num - tabStop) (char ' ')})) ]
438403
439404-- parse raw text for one list item, excluding start marker and continuations
440−rawListItem start = try (do
405+rawListItem start = try $ do
441406 markerLength <- start
442407 firstLine <- manyTill anyChar newline
443408 restLines <- many (listLine markerLength)
444− return (markerLength, (firstLine ++ "\n" ++ (concat restLines))))
409+ return (markerLength, (firstLine ++ "\n" ++ (concat restLines)))
445410
446411-- continuation of a list item - indented and separated by blankline or
447412-- (in compact lists) endline.
@@ -473,10 +438,11 @@ listItem start = try (do
473438 updateState (\st -> st {stateParserContext = oldContext})
474439 return parsed)
475440
476−orderedList = try (do
477− items <- many1 (listItem orderedListStart)
441+orderedList = try $ do
442+ (start, style, delim) <- lookAhead anyOrderedListMarker
443+ items <- many1 (listItem (orderedListStart style delim))
478444 let items' = compactify items
479− return (OrderedList items'))
445+ return (OrderedList (start, style, delim) items')
480446
481447bulletList = try (do
482448 items <- many1 (listItem bulletListStart)
@@ -611,7 +577,8 @@ endline = try (do
611577 -- parse potential list-starts at beginning of line differently in a list:
612578 st <- getState
613579 if ((stateParserContext st) == ListItemState)
614− then notFollowedBy' (choice [orderedListStart, bulletListStart])
580+ then do notFollowedBy' anyOrderedListMarker
581+ notFollowedBy' bulletListStart
615582 else option () pzero
616583 return Space)
617584
src/Text/Pandoc/Shared.hs+160−6
@@ -43,6 +43,8 @@ module Text.Pandoc.Shared (
4343 removeLeadingSpace,
4444 removeTrailingSpace,
4545 stripFirstAndLast,
46+ camelCaseToHyphenated,
47+ toRomanNumeral,
4648 -- * Parsing
4749 readWith,
4850 testStringWith,
@@ -59,9 +61,12 @@ module Text.Pandoc.Shared (
5961 nullBlock,
6062 failIfStrict,
6163 escaped,
64+ anyOrderedListMarker,
65+ orderedListMarker,
6266 -- * Native format prettyprinting
6367 prettyPandoc,
6468 -- * Pandoc block and inline list processing
69+ orderedListMarkers,
6570 normalizeSpaces,
6671 compactify,
6772 Element (..),
@@ -77,8 +82,9 @@ module Text.Pandoc.Shared (
7782 ) where
7883import Text.Pandoc.Definition
7984import Text.ParserCombinators.Parsec
85+import Text.Pandoc.ParserCombinators
8086import Text.Pandoc.Entities ( decodeEntities, escapeStringForXML )
81−import Data.Char ( toLower, ord )
87+import Data.Char ( toLower, toUpper, ord, chr, isLower, isUpper )
8288import Data.List ( find, groupBy, isPrefixOf )
8389
8490-- | Parse a string with a given parser and state.
@@ -199,6 +205,105 @@ escaped parser = try (do
199205 result <- parser
200206 return (Str [result]))
201207
208+-- | Parses an uppercase roman numeral and returns (UpperRoman, number).
209+upperRoman :: GenParser Char st (ListNumberStyle, Int)
210+upperRoman = do
211+ num <- romanNumeral True
212+ return (UpperRoman, num)
213+
214+-- | Parses a lowercase roman numeral and returns (LowerRoman, number).
215+lowerRoman :: GenParser Char st (ListNumberStyle, Int)
216+lowerRoman = do
217+ num <- romanNumeral False
218+ return (LowerRoman, num)
219+
220+-- | Parses a decimal numeral and returns (Decimal, number).
221+decimal :: GenParser Char st (ListNumberStyle, Int)
222+decimal = do
223+ num <- many1 digit
224+ return (Decimal, read num)
225+
226+-- | Parses a '#' returns (DefaultStyle, 1).
227+defaultNum :: GenParser Char st (ListNumberStyle, Int)
228+defaultNum = do
229+ char '#'
230+ return (DefaultStyle, 1)
231+
232+-- | Parses a lowercase letter and returns (LowerAlpha, number).
233+lowerAlpha :: GenParser Char st (ListNumberStyle, Int)
234+lowerAlpha = do
235+ ch <- oneOf ['a'..'z']
236+ return (LowerAlpha, ord ch - ord 'a' + 1)
237+
238+-- | Parses an uppercase letter and returns (UpperAlpha, number).
239+upperAlpha :: GenParser Char st (ListNumberStyle, Int)
240+upperAlpha = do
241+ ch <- oneOf ['A'..'Z']
242+ return (UpperAlpha, ord ch - ord 'A' + 1)
243+
244+-- | Parses a roman numeral i or I
245+romanOne :: GenParser Char st (ListNumberStyle, Int)
246+romanOne = (do char 'i'
247+ return (LowerRoman, 1)) <|>
248+ (do char 'I'
249+ return (UpperRoman, 1))
250+
251+-- | Parses an ordered list marker and returns list attributes.
252+anyOrderedListMarker :: GenParser Char st ListAttributes
253+anyOrderedListMarker = choice $ [delimParser numParser | delimParser <-
254+ [inPeriod, inOneParen, inTwoParens],
255+ numParser <- [decimal, defaultNum, romanOne,
256+ lowerAlpha, lowerRoman, upperAlpha, upperRoman]]
257+
258+-- | Parses a list number (num) followed by a period, returns list attributes.
259+inPeriod :: GenParser Char st (ListNumberStyle, Int)
260+ -> GenParser Char st ListAttributes
261+inPeriod num = try $ do
262+ (style, start) <- num
263+ char '.'
264+ let delim = if style == DefaultStyle
265+ then DefaultDelim
266+ else Period
267+ return (start, style, delim)
268+
269+-- | Parses a list number (num) followed by a paren, returns list attributes.
270+inOneParen :: GenParser Char st (ListNumberStyle, Int)
271+ -> GenParser Char st ListAttributes
272+inOneParen num = try $ do
273+ (style, start) <- num
274+ char ')'
275+ return (start, style, OneParen)
276+
277+-- | Parses a list number (num) enclosed in parens, returns list attributes.
278+inTwoParens :: GenParser Char st (ListNumberStyle, Int)
279+ -> GenParser Char st ListAttributes
280+inTwoParens num = try $ do
281+ char '('
282+ (style, start) <- num
283+ char ')'
284+ return (start, style, TwoParens)
285+
286+-- | Parses an ordered list marker with a given style and delimiter,
287+-- returns number.
288+orderedListMarker :: ListNumberStyle
289+ -> ListNumberDelim
290+ -> GenParser Char st Int
291+orderedListMarker style delim = do
292+ let num = case style of
293+ DefaultStyle -> decimal <|> defaultNum
294+ Decimal -> decimal
295+ UpperRoman -> upperRoman
296+ LowerRoman -> lowerRoman
297+ UpperAlpha -> upperAlpha
298+ LowerAlpha -> lowerAlpha
299+ let context = case delim of
300+ DefaultDelim -> inPeriod
301+ Period -> inPeriod
302+ OneParen -> inOneParen
303+ TwoParens -> inTwoParens
304+ (start, style, delim) <- context num
305+ return start
306+
202307-- | Indent string as a block.
203308indentBy :: Int -- ^ Number of spaces to indent the block
204309 -> Int -- ^ Number of spaces (rel to block) to indent first line
@@ -222,9 +327,10 @@ prettyBlockList indent blocks = indentBy indent (-2) $ "[ " ++
222327prettyBlock :: Block -> String
223328prettyBlock (BlockQuote blocks) = "BlockQuote\n " ++
224329 (prettyBlockList 2 blocks)
225−prettyBlock (OrderedList blockLists) =
226− "OrderedList\n" ++ indentBy 2 0 ("[ " ++ (joinWithSep ", "
227− (map (\blocks -> prettyBlockList 2 blocks) blockLists))) ++ " ]"
330+prettyBlock (OrderedList attribs blockLists) =
331+ "OrderedList " ++ show attribs ++ "\n" ++ indentBy 2 0 ("[ " ++
332+ (joinWithSep ", " $ map (\blocks -> prettyBlockList 2 blocks)
333+ blockLists)) ++ " ]"
228334prettyBlock (BulletList blockLists) = "BulletList\n" ++
229335 indentBy 2 0 ("[ " ++ (joinWithSep ", "
230336 (map (\blocks -> prettyBlockList 2 blocks) blockLists))) ++ " ]"
@@ -317,9 +423,17 @@ removeTrailingSpace :: String -> String
317423removeTrailingSpace = reverse . removeLeadingSpace . reverse
318424
319425-- | Strip leading and trailing characters from string
426+stripFirstAndLast :: String -> String
320427stripFirstAndLast str =
321428 drop 1 $ take ((length str) - 1) str
322429
430+-- | Change CamelCase word to hyphenated lowercase (e.g., camel-case).
431+camelCaseToHyphenated :: String -> String
432+camelCaseToHyphenated "" = ""
433+camelCaseToHyphenated (a:b:rest) | isLower a && isUpper b =
434+ a:'-':(toLower b):(camelCaseToHyphenated rest)
435+camelCaseToHyphenated (a:rest) = (toLower a):(camelCaseToHyphenated rest)
436+
323437-- | Replace each occurrence of one sublist in a list with another.
324438substitute :: (Eq a) => [a] -> [a] -> [a] -> [a]
325439substitute _ _ [] = []
@@ -344,6 +458,46 @@ splitByIndices (x:xs) lst =
344458 let (first, rest) = splitAt x lst in
345459 first:(splitByIndices (map (\y -> y - x) xs) rest)
346460
461+-- | Generate infinite lazy list of markers for an ordered list,
462+-- depending on list attributes.
463+orderedListMarkers :: (Int, ListNumberStyle, ListNumberDelim) -> [String]
464+orderedListMarkers (start, numstyle, numdelim) =
465+ let singleton c = [c]
466+ seq = case numstyle of
467+ DefaultStyle -> map show [start..]
468+ Decimal -> map show [start..]
469+ UpperAlpha -> drop (start - 1) $ cycle $ map singleton ['A'..'Z']
470+ LowerAlpha -> drop (start - 1) $ cycle $ map singleton ['a'..'z']
471+ UpperRoman -> map toRomanNumeral [start..]
472+ LowerRoman -> map (map toLower . toRomanNumeral) [start..]
473+ inDelim str = case numdelim of
474+ DefaultDelim -> str ++ "."
475+ Period -> str ++ "."
476+ OneParen -> str ++ ")"
477+ TwoParens -> "(" ++ str ++ ")"
478+ in map inDelim seq
479+
480+-- | Convert number < 4000 to uppercase roman numeral.
481+toRomanNumeral :: Int -> String
482+toRomanNumeral x =
483+ if x >= 4000 || x < 0
484+ then "?"
485+ else case x of
486+ x | x >= 1000 -> "M" ++ toRomanNumeral (x - 1000)
487+ x | x >= 900 -> "CM" ++ toRomanNumeral (x - 900)
488+ x | x >= 500 -> "D" ++ toRomanNumeral (x - 500)
489+ x | x >= 400 -> "CD" ++ toRomanNumeral (x - 400)
490+ x | x >= 100 -> "C" ++ toRomanNumeral (x - 100)
491+ x | x >= 90 -> "XC" ++ toRomanNumeral (x - 90)
492+ x | x >= 50 -> "L" ++ toRomanNumeral (x - 50)
493+ x | x >= 40 -> "XL" ++ toRomanNumeral (x - 40)
494+ x | x >= 10 -> "X" ++ toRomanNumeral (x - 10)
495+ x | x >= 9 -> "IX" ++ toRomanNumeral (x - 5)
496+ x | x >= 5 -> "V" ++ toRomanNumeral (x - 5)
497+ x | x >= 4 -> "IV" ++ toRomanNumeral (x - 4)
498+ x | x >= 1 -> "I" ++ toRomanNumeral (x - 1)
499+ 0 -> ""
500+
347501-- | Normalize a list of inline elements: remove leading and trailing
348502-- @Space@ elements, collapse double @Space@s into singles, and
349503-- remove empty Str elements.
@@ -383,8 +537,8 @@ containsPara [] = False
383537containsPara ((Para a):rest) = True
384538containsPara ((BulletList items):rest) = (any containsPara items) ||
385539 (containsPara rest)
386−containsPara ((OrderedList items):rest) = (any containsPara items) ||
387− (containsPara rest)
540+containsPara ((OrderedList _ items):rest) = (any containsPara items) ||
541+ (containsPara rest)
388542containsPara (x:rest) = containsPara rest
389543
390544-- | Data structure for defining hierarchical Pandoc documents
src/Text/Pandoc/Writers/ConTeXt.hs+18−3
@@ -122,9 +122,20 @@ blockToConTeXt (RawHtml str) = return ""
122122blockToConTeXt (BulletList lst) = do
123123 contents <- mapM listItemToConTeXt lst
124124 return $ "\\startltxitem\n" ++ concat contents ++ "\\stopltxitem\n"
125−blockToConTeXt (OrderedList lst) = do
126− contents <- mapM listItemToConTeXt lst
127− return $ "\\startltxenum\n" ++ concat contents ++ "\\stopltxenum\n"
125+blockToConTeXt (OrderedList attribs lst) = case attribs of
126+ (1, DefaultStyle, DefaultDelim) -> do
127+ contents <- mapM listItemToConTeXt lst
128+ return $ "\\startltxenum\n" ++ concat contents ++ "\\stopltxenum\n"
129+ _ -> do
130+ let markers = take (length lst) $ orderedListMarkers attribs
131+ contents <- zipWithM orderedListItemToConTeXt markers lst
132+ let markerWidth = maximum $ map length markers
133+ let markerWidth' = if markerWidth < 3
134+ then ""
135+ else "[width=" ++
136+ show ((markerWidth + 2) `div` 2) ++ "em]"
137+ return $ "\\startitemize" ++ markerWidth' ++ "\n" ++ concat contents ++
138+ "\\stopitemize\n"
128139blockToConTeXt (DefinitionList lst) =
129140 mapM defListItemToConTeXt lst >>= (return . (++ "\n") . concat)
130141blockToConTeXt HorizontalRule = return "\\thinrule\n\n"
@@ -163,6 +174,10 @@ listItemToConTeXt list = do
163174 contents <- blockListToConTeXt list
164175 return $ "\\item " ++ contents
165176
177+orderedListItemToConTeXt marker list = do
178+ contents <- blockListToConTeXt list
179+ return $ "\\sym{" ++ marker ++ "} " ++ contents
180+
166181defListItemToConTeXt (term, def) = do
167182 term' <- inlineListToConTeXt term
168183 def' <- blockListToConTeXt def
src/Text/Pandoc/Writers/Docbook.hs+15−2
@@ -173,8 +173,21 @@ blockToDocbook opts (CodeBlock str) =
173173 text "<screen>\n" <> text (escapeStringForXML str) <> text "\n</screen>"
174174blockToDocbook opts (BulletList lst) =
175175 inTagsIndented "itemizedlist" $ listItemsToDocbook opts lst
176−blockToDocbook opts (OrderedList lst) =
177− inTagsIndented "orderedlist" $ listItemsToDocbook opts lst
176+blockToDocbook opts (OrderedList _ []) = empty
177+blockToDocbook opts (OrderedList (start, numstyle, numdelim) (first:rest)) =
178+ let attribs = case numstyle of
179+ DefaultStyle -> []
180+ Decimal -> [("numeration", "arabic")]
181+ UpperAlpha -> [("numeration", "upperalpha")]
182+ LowerAlpha -> [("numeration", "loweralpha")]
183+ UpperRoman -> [("numeration", "upperroman")]
184+ LowerRoman -> [("numeration", "lowerroman")]
185+ items = if start == 1
186+ then listItemsToDocbook opts (first:rest)
187+ else (inTags True "listitem" [("override",show start)]
188+ (blocksToDocbook opts $ map plainToPara first)) $$
189+ listItemsToDocbook opts rest
190+ in inTags True "orderedlist" attribs items
178191blockToDocbook opts (DefinitionList lst) =
179192 inTagsIndented "variablelist" $ deflistItemsToDocbook opts lst
180193blockToDocbook opts (RawHtml str) = text str -- raw XML block
src/Text/Pandoc/Writers/HTML.hs+51−27
@@ -36,15 +36,21 @@ import Text.Regex ( mkRegex, matchRegex )
3636import Numeric ( showHex )
3737import Data.Char ( ord, toLower )
3838import Data.List ( isPrefixOf, partition, intersperse )
39+import qualified Data.Set as S
3940import Control.Monad.State
40−import Text.XHtml.Strict
41+import Text.XHtml.Transitional
4142
4243data WriterState = WriterState
43− { stNotes :: [Html] -- ^ List of notes
44− , stIds :: [String] -- ^ List of header identifiers
45− , stHead :: [Html] -- ^ Html to include in header
44+ { stNotes :: [Html] -- ^ List of notes
45+ , stIds :: [String] -- ^ List of header identifiers
46+ , stMath :: Bool -- ^ Math is used in document
47+ , stCSS :: S.Set String -- ^ CSS to include in header
4648 } deriving Show
4749
50+defaultWriterState :: WriterState
51+defaultWriterState = WriterState {stNotes= [], stIds = [],
52+ stMath = False, stCSS = S.empty}
53+
4854-- | Convert Pandoc document to Html string.
4955writeHtmlString :: WriterOptions -> Pandoc -> String
5056writeHtmlString opts =
@@ -56,8 +62,7 @@ writeHtmlString opts =
5662writeHtml :: WriterOptions -> Pandoc -> Html
5763writeHtml opts (Pandoc (Meta tit authors date) blocks) =
5864 let titlePrefix = writerTitlePrefix opts
59− topTitle = evalState (inlineListToHtml opts tit)
60− (WriterState {stNotes = [], stIds = [], stHead = []})
65+ topTitle = evalState (inlineListToHtml opts tit) defaultWriterState
6166 topTitle' = if null titlePrefix
6267 then topTitle
6368 else titlePrefix +++ " - " +++ topTitle
@@ -81,8 +86,19 @@ writeHtml opts (Pandoc (Meta tit authors date) blocks) =
8186 else noHtml
8287 (blocks', newstate) =
8388 runState (blockListToHtml opts blocks)
84− (WriterState {stNotes = [], stIds = ids, stHead = []})
85− head = header $ metadata +++ toHtmlFromList (stHead newstate) +++
89+ (defaultWriterState {stIds = ids})
90+ cssLines = stCSS newstate
91+ css = if S.null cssLines
92+ then noHtml
93+ else style ! [thetype "text/css"] $ primHtml $
94+ '\n':(unlines $ S.toList cssLines)
95+ math = if stMath newstate
96+ then case writerASCIIMathMLURL opts of
97+ Just path -> script ! [src path,
98+ thetype "text/javascript"] $ noHtml
99+ Nothing -> primHtml asciiMathMLScript
100+ else noHtml
101+ head = header $ metadata +++ math +++ css +++
86102 primHtml (writerHeader opts)
87103 notes = reverse (stNotes newstate)
88104 before = primHtml $ writerIncludeBefore opts
@@ -100,7 +116,7 @@ tableOfContents opts headers ids =
100116 let opts' = opts { writerIgnoreNotes = True }
101117 contentsTree = hierarchicalize headers
102118 contents = evalState (mapM (elementToListItem opts') contentsTree)
103− (WriterState {stNotes= [], stIds = ids, stHead = []})
119+ (defaultWriterState {stIds = ids})
104120 in thediv ! [identifier "toc"] $ unordList contents
105121
106122-- | Converts an Element to a list item for a table of contents,
@@ -177,12 +193,12 @@ isPunctuation c =
177193 then True
178194 else False
179195
180−-- | Add Html to document header.
181−addToHeader :: Html -> State WriterState ()
182−addToHeader item = do
196+-- | Add CSS for document header.
197+addToCSS :: String -> State WriterState ()
198+addToCSS item = do
183199 st <- get
184− let current = stHead st
185− put $ st {stHead = (item:current)}
200+ let current = stCSS st
201+ put $ st {stCSS = (S.insert item current)}
186202
187203-- | Convert Pandoc inline list to plain text identifier.
188204inlineListToIdentifier :: [Inline] -> String
@@ -241,8 +257,9 @@ blockToHtml opts block =
241257 case blocks of
242258 [BulletList lst] -> blockToHtml (opts {writerIncremental = inc})
243259 (BulletList lst)
244− [OrderedList lst] -> blockToHtml (opts {writerIncremental = inc})
245− (OrderedList lst)
260+ [OrderedList attribs lst] ->
261+ blockToHtml (opts {writerIncremental = inc})
262+ (OrderedList attribs lst)
246263 otherwise -> blockListToHtml opts blocks >>=
247264 (return . blockquote)
248265 else blockListToHtml opts blocks >>= (return . blockquote)
@@ -272,10 +289,23 @@ blockToHtml opts block =
272289 then [theclass "incremental"]
273290 else []
274291 return $ unordList ! attribs $ contents
275− (OrderedList lst) -> do contents <- mapM (blockListToHtml opts) lst
276− let attribs = if writerIncremental opts
292+ (OrderedList (startnum, numstyle, _) lst) -> do
293+ contents <- mapM (blockListToHtml opts) lst
294+ let numstyle' = camelCaseToHyphenated $ show numstyle
295+ let attribs = (if writerIncremental opts
277296 then [theclass "incremental"]
278− else []
297+ else []) ++
298+ (if startnum /= 1
299+ then [start startnum]
300+ else []) ++
301+ (if numstyle /= DefaultStyle
302+ then [theclass numstyle']
303+ else [])
304+ if numstyle /= DefaultStyle
305+ then addToCSS $ "ol." ++ numstyle' ++
306+ " { list-style-type: " ++
307+ numstyle' ++ "; }"
308+ else return ()
279309 return $ ordList ! attribs $ contents
280310 (DefinitionList lst) -> do contents <- mapM (\(term, def) ->
281311 do term' <- inlineListToHtml opts term
@@ -342,8 +372,7 @@ inlineToHtml opts inline =
342372 (Emph lst) -> inlineListToHtml opts lst >>= (return . emphasize)
343373 (Strong lst) -> inlineListToHtml opts lst >>= (return . strong)
344374 (Code str) -> return $ thecode << str
345− (Strikeout lst) -> addToHeader (style ! [thetype "text/css"] $ (stringToHtml
346− ".strikeout { text-decoration: line-through; }")) >>
375+ (Strikeout lst) -> addToCSS ".strikeout { text-decoration: line-through; }" >>
347376 inlineListToHtml opts lst >>=
348377 (return . (thespan ! [theclass "strikeout"]))
349378 (Superscript lst) -> inlineListToHtml opts lst >>= (return . sup)
@@ -357,12 +386,7 @@ inlineToHtml opts inline =
357386 do contents <- inlineListToHtml opts lst
358387 return $ leftQuote +++ contents +++ rightQuote
359388 (TeX str) -> do if writerUseASCIIMathML opts
360− then addToHeader $
361− case writerASCIIMathMLURL opts of
362− Just path -> script ! [src path,
363− thetype "text/javascript"] $
364− noHtml
365− Nothing -> primHtml asciiMathMLScript
389+ then modify (\st -> st {stMath = True})
366390 else return ()
367391 return $ stringToHtml str
368392 (HtmlInline str) -> return $ primHtml str
src/Text/Pandoc/Writers/LaTeX.hs+20−4
@@ -36,10 +36,12 @@ import Text.Printf ( printf )
3636import Data.List ( (\\), isInfixOf )
3737import qualified Data.Set as S
3838import Control.Monad.State
39+import Data.Char ( toLower )
3940
4041data WriterState =
4142 WriterState { stIncludes :: S.Set String -- strings to include in header
42− , stInNote :: Bool } -- @True@ if we're in a note
43+ , stInNote :: Bool -- @True@ if we're in a note
44+ , stOLLevel :: Int } -- level of ordered list nesting
4345
4446-- | Add line to header.
4547addToHeader :: String -> State WriterState ()
@@ -52,7 +54,7 @@ addToHeader str = do
5254writeLaTeX :: WriterOptions -> Pandoc -> String
5355writeLaTeX options document =
5456 evalState (pandocToLaTeX options document) $
55− WriterState { stIncludes = S.empty, stInNote = False }
57+ WriterState { stIncludes = S.empty, stInNote = False, stOLLevel = 1 }
5658
5759pandocToLaTeX :: WriterOptions -> Pandoc -> State WriterState String
5860pandocToLaTeX options (Pandoc meta blocks) = do
@@ -137,9 +139,23 @@ blockToLaTeX (RawHtml str) = return ""
137139blockToLaTeX (BulletList lst) = do
138140 items <- mapM listItemToLaTeX lst
139141 return $ "\\begin{itemize}\n" ++ concat items ++ "\\end{itemize}\n"
140−blockToLaTeX (OrderedList lst) = do
142+blockToLaTeX (OrderedList (start, numstyle, numdelim) lst) = do
143+ st <- get
144+ let oldlevel = stOLLevel st
145+ put $ st {stOLLevel = oldlevel + 1}
141146 items <- mapM listItemToLaTeX lst
142− return $ "\\begin{enumerate}\n" ++ concat items ++ "\\end{enumerate}\n"
147+ put $ st {stOLLevel = oldlevel}
148+ exemplar <- if numstyle /= DefaultStyle || numdelim /= DefaultDelim
149+ then do addToHeader "\\usepackage{enumerate}"
150+ return $ "[" ++ head (orderedListMarkers (1, numstyle, numdelim)) ++ "]"
151+ else return ""
152+ let resetcounter = if start /= 1 && oldlevel <= 4
153+ then "\\setcounter{enum" ++
154+ map toLower (toRomanNumeral oldlevel) ++
155+ "}{" ++ show (start - 1) ++ "}\n"
156+ else ""
157+ return $ "\\begin{enumerate}" ++ exemplar ++ "\n" ++
158+ resetcounter ++ concat items ++ "\\end{enumerate}\n"
143159blockToLaTeX (DefinitionList lst) = do
144160 items <- mapM defListItemToLaTeX lst
145161 return $ "\\begin{description}\n" ++ concat items ++ "\\end{description}\n"
src/Text/Pandoc/Writers/Man.hs+16−17
@@ -173,9 +173,11 @@ blockToMan opts (Table caption alignments widths headers rows) =
173173blockToMan opts (BulletList items) = do
174174 contents <- mapM (bulletListItemToMan opts) items
175175 return (vcat contents)
176−blockToMan opts (OrderedList items) = do
177− contents <- mapM (\(item, num) -> orderedListItemToMan opts item num) $
178− zip [1..] items
176+blockToMan opts (OrderedList attribs items) = do
177+ let markers = take (length items) $ orderedListMarkers attribs
178+ let indent = 1 + (maximum $ map length markers)
179+ contents <- mapM (\(num, item) -> orderedListItemToMan opts num indent item) $
180+ zip markers items
179181 return (vcat contents)
180182blockToMan opts (DefinitionList items) = do
181183 contents <- mapM (definitionListItemToMan opts) items
@@ -201,25 +203,22 @@ bulletListItemToMan opts (first:rest) = do
201203
202204-- | Convert ordered list item (a list of blocks) to man.
203205orderedListItemToMan :: WriterOptions -- ^ options
204− -> Int -- ^ ordinal number of list item
205− -> [Block] -- ^ list item (list of blocks)
206+ -> String -- ^ order marker for list item
207+ -> Int -- ^ number of spaces to indent
208+ -> [Block] -- ^ list item (list of blocks)
206209 -> State WriterState Doc
207−orderedListItemToMan _ _ [] = return empty
208−orderedListItemToMan opts num ((Para first):rest) =
209− orderedListItemToMan opts num ((Plain first):rest)
210−orderedListItemToMan opts num ((Plain first):rest) = do
211− first' <- blockToMan opts (Plain first)
210+orderedListItemToMan _ _ _ [] = return empty
211+orderedListItemToMan opts num indent ((Para first):rest) =
212+ orderedListItemToMan opts num indent ((Plain first):rest)
213+orderedListItemToMan opts num indent (first:rest) = do
214+ first' <- blockToMan opts first
212215 rest' <- blockListToMan opts rest
213− let first'' = text (".IP " ++ show num ++ "." ++ " 4") $$ first'
216+ let num' = printf ("%" ++ show (indent - 1) ++ "s") num
217+ let first'' = text (".IP \"" ++ num' ++ "\" " ++ show indent) $$ first'
214218 let rest'' = if null rest
215219 then empty
216220 else text ".RS 4" $$ rest' $$ text ".RE"
217− return (first'' $$ rest'')
218−orderedListItemToMan opts num (first:rest) = do
219− first' <- blockToMan opts first
220− rest' <- blockListToMan opts rest
221− return $ text (".IP " ++ show num ++ "." ++ " 4") $$ first' $$
222− rest' $$ text ".RE"
221+ return $ first'' $$ rest''
223222
224223-- | Convert definition list item (label, list of blocks) to man.
225224definitionListItemToMan :: WriterOptions
src/Text/Pandoc/Writers/Markdown.hs+17−14
@@ -57,7 +57,7 @@ pandocToMarkdown opts (Pandoc meta blocks) = do
5757 after' = if null after then empty else text after
5858 metaBlock <- metaToMarkdown opts meta
5959 let head = if (writerStandalone opts)
60− then metaBlock $$ text (writerHeader opts)
60+ then metaBlock $+$ text (writerHeader opts)
6161 else empty
6262 let headerBlocks = filter isHeaderBlock blocks
6363 let toc = if writerTableOfContents opts
@@ -68,8 +68,8 @@ pandocToMarkdown opts (Pandoc meta blocks) = do
6868 notes' <- notesToMarkdown opts (reverse notes)
6969 (_, refs) <- get -- note that the notes may contain refs
7070 refs' <- keyTableToMarkdown opts (reverse refs)
71− return $ head $$ before' $$ toc $$ body $$ text "" $$
72− notes' $$ text "" $$ refs' $$ after'
71+ return $ head $+$ before' $+$ toc $+$ body $+$ text "" $+$
72+ notes' $+$ text "" $+$ refs' $+$ after'
7373
7474-- | Return markdown representation of reference key table.
7575keyTableToMarkdown :: WriterOptions -> KeyTable -> State WriterState Doc
@@ -116,7 +116,7 @@ metaToMarkdown opts (Meta title authors date) = do
116116 title' <- titleToMarkdown opts title
117117 authors' <- authorsToMarkdown authors
118118 date' <- dateToMarkdown date
119− return $ title' $$ authors' $$ date'
119+ return $ title' $+$ authors' $+$ date'
120120
121121titleToMarkdown :: WriterOptions -> [Inline] -> State WriterState Doc
122122titleToMarkdown opts [] = return empty
@@ -173,7 +173,7 @@ blockToMarkdown opts (Table caption aligns widths headers rows) = do
173173 caption' <- inlineListToMarkdown opts caption
174174 let caption'' = if null caption
175175 then empty
176− else text "" $$ (text "Table: " <> caption')
176+ else text "" $+$ (text "Table: " <> caption')
177177 headers' <- mapM (blockListToMarkdown opts) headers
178178 let widthsInChars = map (floor . (78 *)) widths
179179 let alignHeader alignment = case alignment of
@@ -199,14 +199,19 @@ blockToMarkdown opts (Table caption aligns widths headers rows) = do
199199 then text ""
200200 else empty
201201 let body = vcat $ intersperse spacer $ map blockToDoc rows'
202− return $ (nest 2 $ border $$ (blockToDoc head) $$ underline $$ body $$
203− border $$ caption'') $$ text ""
202+ return $ (nest 2 $ border $+$ (blockToDoc head) $+$ underline $+$ body $+$
203+ border $+$ caption'') <> text "\n"
204204blockToMarkdown opts (BulletList items) = do
205205 contents <- mapM (bulletListItemToMarkdown opts) items
206206 return $ (vcat contents) <> text "\n"
207−blockToMarkdown opts (OrderedList items) = do
207+blockToMarkdown opts (OrderedList attribs items) = do
208+ let markers = orderedListMarkers attribs
209+ let markers' = map (\m -> if length m < 3
210+ then m ++ replicate (3 - length m) ' '
211+ else m)
212+ markers
208213 contents <- mapM (\(item, num) -> orderedListItemToMarkdown opts item num) $
209− zip [1..] items
214+ zip markers' items
210215 return $ (vcat contents) <> text "\n"
211216blockToMarkdown opts (DefinitionList items) = do
212217 contents <- mapM (definitionListItemToMarkdown opts) items
@@ -220,14 +225,12 @@ bulletListItemToMarkdown opts items = do
220225
221226-- | Convert ordered list item (a list of blocks) to markdown.
222227orderedListItemToMarkdown :: WriterOptions -- ^ options
223− -> Int -- ^ ordinal number of list item
228+ -> String -- ^ list item marker
224229 -> [Block] -- ^ list item (list of blocks)
225230 -> State WriterState Doc
226−orderedListItemToMarkdown opts num items = do
231+orderedListItemToMarkdown opts marker items = do
227232 contents <- blockListToMarkdown opts items
228− let spacer = if (num < 10) then " " else ""
229− return $ hang (text ((show num) ++ "." ++ spacer)) (writerTabStop opts)
230− contents
233+ return $ hang (text marker) (writerTabStop opts) contents
231234
232235-- | Convert definition list item (label, list of blocks) to markdown.
233236definitionListItemToMarkdown :: WriterOptions
src/Text/Pandoc/Writers/RST.hs+33−23
@@ -57,7 +57,7 @@ pandocToRST opts (Pandoc meta blocks) = do
5757 after' = if null after then empty else text after
5858 metaBlock <- metaToRST opts meta
5959 let head = if (writerStandalone opts)
60− then metaBlock $$ text (writerHeader opts)
60+ then metaBlock $+$ text (writerHeader opts)
6161 else empty
6262 body <- blockListToRST opts blocks
6363 (notes, _, _) <- get
@@ -65,8 +65,8 @@ pandocToRST opts (Pandoc meta blocks) = do
6565 (_, refs, pics) <- get -- note that the notes may contain refs
6666 refs' <- keyTableToRST opts (reverse refs)
6767 pics' <- pictTableToRST opts (reverse pics)
68− return $ head <> (before' $$ body $$ notes' <> text "\n" $$ refs' $$
69− pics' $$ after')
68+ return $ head $+$ before' $+$ body $+$ notes' $+$ text "" $+$ refs' $+$
69+ pics' $+$ after'
7070
7171-- | Return RST representation of reference key table.
7272keyTableToRST :: WriterOptions -> KeyTable -> State WriterState Doc
@@ -131,9 +131,9 @@ metaToRST opts (Meta title authors date) = do
131131 authors' <- authorsToRST authors
132132 date' <- dateToRST date
133133 let toc = if writerTableOfContents opts
134− then text "" $$ text ".. contents::"
134+ then text "" $+$ text ".. contents::"
135135 else empty
136− return $ title' $$ authors' $$ date' $$ toc $$ text ""
136+ return $ title' $+$ authors' $+$ date' $+$ toc
137137
138138titleToRST :: WriterOptions -> [Inline] -> State WriterState Doc
139139titleToRST opts [] = return empty
@@ -141,13 +141,13 @@ titleToRST opts lst = do
141141 contents <- inlineListToRST opts lst
142142 let titleLength = length $ render contents
143143 let border = text (replicate titleLength '=')
144− return $ border <> char '\n' <> contents <> char '\n' <> border <> text "\n"
144+ return $ border $+$ contents $+$ border <> text "\n"
145145
146146authorsToRST :: [String] -> State WriterState Doc
147147authorsToRST [] = return empty
148148authorsToRST (first:rest) = do
149149 rest' <- authorsToRST rest
150− return $ (text ":Author: " <> text first) $$ rest'
150+ return $ (text ":Author: " <> text first) $+$ rest'
151151
152152dateToRST :: String -> State WriterState Doc
153153dateToRST [] = return empty
@@ -161,21 +161,23 @@ blockToRST opts Null = return empty
161161blockToRST opts (Plain inlines) = wrappedRST opts inlines
162162blockToRST opts (Para [TeX str]) =
163163 let str' = if (endsWith '\n' str) then (str ++ "\n") else (str ++ "\n\n") in
164− return $ hang (text "\n.. raw:: latex\n") 3 (vcat $ map text (lines str'))
164+ return $ hang (text "\n.. raw:: latex\n") 3
165+ (vcat $ map text (lines str'))
165166blockToRST opts (Para inlines) = do
166167 contents <- wrappedRST opts inlines
167168 return $ contents <> text "\n"
168169blockToRST opts (RawHtml str) =
169170 let str' = if (endsWith '\n' str) then (str ++ "\n") else (str ++ "\n\n") in
170− return $ hang (text "\n.. raw:: html\n") 3 (vcat $ map text (lines str'))
171+ return $ hang (text "\n.. raw:: html\n") 3
172+ (vcat $ map text (lines str'))
171173blockToRST opts HorizontalRule = return $ text "--------------\n"
172174blockToRST opts (Header level inlines) = do
173175 contents <- inlineListToRST opts inlines
174176 let headerLength = length $ render contents
175177 let headerChar = if (level > 5) then ' ' else "=-~^'" !! (level - 1)
176178 let border = text $ replicate headerLength headerChar
177− return $ contents <> char '\n' <> border <> char '\n'
178−blockToRST opts (CodeBlock str) = return $ (text "::\n") $$ text "" $$
179+ return $ contents $+$ border <> text "\n"
180+blockToRST opts (CodeBlock str) = return $ (text "::\n") $+$
179181 (nest (writerTabStop opts) $ vcat $ map text (lines str)) <> text "\n"
180182blockToRST opts (BlockQuote blocks) = do
181183 contents <- blockListToRST opts blocks
@@ -184,7 +186,7 @@ blockToRST opts (Table caption aligns widths headers rows) = do
184186 caption' <- inlineListToRST opts caption
185187 let caption'' = if null caption
186188 then empty
187− else text "" $$ (text "Table: " <> caption')
189+ else text "" $+$ (text "Table: " <> caption')
188190 headers' <- mapM (blockListToRST opts) headers
189191 let widthsInChars = map (floor . (78 *)) widths
190192 let alignHeader alignment = case alignment of
@@ -210,15 +212,25 @@ blockToRST opts (Table caption aligns widths headers rows) = do
210212 map (\l -> text $ replicate l ch) widthsInChars) <>
211213 char ch <> char '+'
212214 let body = vcat $ intersperse (border '-') $ map blockToDoc rows'
213− return $ border '-' $$ blockToDoc head $$ border '=' $$ body $$
215+ return $ border '-' $+$ blockToDoc head $+$ border '=' $+$ body $+$
214216 border '-' $$ caption'' $$ text ""
215217blockToRST opts (BulletList items) = do
216218 contents <- mapM (bulletListItemToRST opts) items
217− return $ (vcat contents) <> text "\n"
218−blockToRST opts (OrderedList items) = do
219+ -- ensure that sublists have preceding blank line
220+ return $ text "" $+$ vcat contents <> text "\n"
221+blockToRST opts (OrderedList (start, style, delim) items) = do
222+ let markers = if start == 1 && style == DefaultStyle && delim == DefaultDelim
223+ then take (length items) $ repeat "#."
224+ else take (length items) $ orderedListMarkers
225+ (start, style, delim)
226+ let maxMarkerLength = maximum $ map length markers
227+ let markers' = map (\m -> let s = maxMarkerLength - length m
228+ in m ++ replicate s ' ')
229+ markers
219230 contents <- mapM (\(item, num) -> orderedListItemToRST opts item num) $
220− zip [1..] items
221− return $ (vcat contents) <> text "\n"
231+ zip markers' items
232+ -- ensure that sublists have preceding blank line
233+ return $ text "" $+$ vcat contents <> text "\n"
222234blockToRST opts (DefinitionList items) = do
223235 contents <- mapM (definitionListItemToRST opts) items
224236 return $ (vcat contents) <> text "\n"
@@ -231,14 +243,12 @@ bulletListItemToRST opts items = do
231243
232244-- | Convert ordered list item (a list of blocks) to RST.
233245orderedListItemToRST :: WriterOptions -- ^ options
234− -> Int -- ^ ordinal number of list item
235− -> [Block] -- ^ list item (list of blocks)
246+ -> String -- ^ marker for list item
247+ -> [Block] -- ^ list item (list of blocks)
236248 -> State WriterState Doc
237−orderedListItemToRST opts num items = do
249+orderedListItemToRST opts marker items = do
238250 contents <- blockListToRST opts items
239− let spacer = if (num < 10) then " " else ""
240− return $ hang (text ((show num) ++ "." ++ spacer)) (writerTabStop opts)
241− contents
251+ return $ hang (text marker) (writerTabStop opts) contents
242252
243253-- | Convert defintion list item (label, list of blocks) to RST.
244254definitionListItemToRST :: WriterOptions -> ([Inline], [Block]) -> State WriterState Doc
src/Text/Pandoc/Writers/RTF.hs+9−7
@@ -132,11 +132,13 @@ bulletMarker indent = case (indent `mod` 720) of
132132 otherwise -> "\\endash "
133133
134134-- | Returns appropriate (list of) ordered list markers for indent level.
135−orderedMarkers :: Int -> [String]
136−orderedMarkers indent =
137− case (indent `mod` 720) of
138− 0 -> map (\x -> show x ++ ".") [1..]
139− otherwise -> map (\x -> show x ++ ".") $ cycle ['a'..'z']
135+orderedMarkers :: Int -> ListAttributes -> [String]
136+orderedMarkers indent (start, style, delim) =
137+ if style == DefaultStyle && delim == DefaultDelim
138+ then case (indent `mod` 720) of
139+ 0 -> orderedListMarkers (start, Decimal, Period)
140+ otherwise -> orderedListMarkers (start, LowerAlpha, Period)
141+ else orderedListMarkers (start, style, delim)
140142
141143-- | Returns RTF header.
142144rtfHeader :: String -- ^ header text
@@ -177,9 +179,9 @@ blockToRTF _ _ (RawHtml str) = ""
177179blockToRTF indent alignment (BulletList lst) =
178180 spaceAtEnd $
179181 concatMap (listItemToRTF alignment indent (bulletMarker indent)) lst
180−blockToRTF indent alignment (OrderedList lst) =
182+blockToRTF indent alignment (OrderedList attribs lst) =
181183 spaceAtEnd $ concat $
182− zipWith (listItemToRTF alignment indent) (orderedMarkers indent) lst
184+ zipWith (listItemToRTF alignment indent) (orderedMarkers indent attribs) lst
183185blockToRTF indent alignment (DefinitionList lst) =
184186 spaceAtEnd $
185187 concatMap (definitionListItemToRTF alignment indent) lst
src/headers/LaTeXHeader+1−1
@@ -1,5 +1,5 @@
11\documentclass{article}
2−\usepackage{ucs}
2+\usepackage[mathletters]{ucs}
33\usepackage[utf8x]{inputenc}
44\setlength{\parindent}{0pt}
55\setlength{\parskip}{6pt plus 2pt minus 1pt}
tests/html-reader.html+56
@@ -232,6 +232,62 @@ These should not be escaped: \$ \\ \> \[ \{
232232</ul>
233233</li>
234234</ul>
235+<h2 id="fancy-list-markers"
236+ >Fancy list markers</h2
237+ ><ol start="2" class="decimal"
238+ ><li
239+ >begins with 2</li
240+ ><li
241+ ><p
242+ >and now 3</p
243+ ><p
244+ >with a continuation</p
245+ ><ol start="4" class="lower-roman"
246+ ><li
247+ >sublist with roman numerals, starting with 4</li
248+ ><li
249+ >more items<ol class="upper-alpha"
250+ ><li
251+ >a subsublist</li
252+ ><li
253+ >a subsublist</li
254+ ></ol
255+ ></li
256+ ></ol
257+ ></li
258+ ></ol
259+ ><p
260+ >Nesting:</p
261+ ><ol class="upper-alpha"
262+ ><li
263+ >Upper Alpha<ol class="upper-roman"
264+ ><li
265+ >Upper Roman.<ol start="6" class="decimal"
266+ ><li
267+ >Decimal start with 6<ol start="3" class="lower-alpha"
268+ ><li
269+ >Lower alpha with paren</li
270+ ></ol
271+ ></li
272+ ></ol
273+ ></li
274+ ></ol
275+ ></li
276+ ></ol
277+ ><p
278+ >Autonumbering:</p
279+ ><ol
280+ ><li
281+ >Autonumber.</li
282+ ><li
283+ >More.<ol
284+ ><li
285+ >Nested.</li
286+ ></ol
287+ ></li
288+ ></ol
289+ ><hr
290+ />
235291<h2>Definition</h2>
236292<dl>
237293 <dt>Violin</dt>
tests/html-reader.native+38−9
@@ -28,7 +28,7 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] [] "")
2828 [ Para [Str "Code",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote:"]
2929 , CodeBlock "sub status {\n print \"working\";\n}"
3030 , Para [Str "A",Space,Str "list:"]
31− , OrderedList
31+ , OrderedList (1,DefaultStyle,DefaultDelim)
3232 [ [ Plain [Str "item",Space,Str "one"] ]
3333 , [ Plain [Str "item",Space,Str "two"] ] ]
3434 , Para [Str "Nested",Space,Str "block",Space,Str "quotes:"]
@@ -44,7 +44,7 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] [] "")
4444 [ Para [Str "Example:"]
4545 , CodeBlock "sub status {\n print \"working\";\n}" ]
4646, BlockQuote
47− [ OrderedList
47+ [ OrderedList (1,DefaultStyle,DefaultDelim)
4848 [ [ Plain [Str "do",Space,Str "laundry"] ]
4949 , [ Plain [Str "take",Space,Str "out",Space,Str "the",Space,Str "trash"] ] ] ]
5050, Para [Str "Here's",Space,Str "a",Space,Str "nested",Space,Str "one:"]
@@ -95,27 +95,27 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] [] "")
9595 , [ Para [Str "Minus",Space,Str "3"] ] ]
9696, Header 2 [Str "Ordered"]
9797, Para [Str "Tight:"]
98−, OrderedList
98+, OrderedList (1,DefaultStyle,DefaultDelim)
9999 [ [ Plain [Str "First"] ]
100100 , [ Plain [Str "Second"] ]
101101 , [ Plain [Str "Third"] ] ]
102102, Para [Str "and:"]
103−, OrderedList
103+, OrderedList (1,DefaultStyle,DefaultDelim)
104104 [ [ Plain [Str "One"] ]
105105 , [ Plain [Str "Two"] ]
106106 , [ Plain [Str "Three"] ] ]
107107, Para [Str "Loose",Space,Str "using",Space,Str "tabs:"]
108−, OrderedList
108+, OrderedList (1,DefaultStyle,DefaultDelim)
109109 [ [ Para [Str "First"] ]
110110 , [ Para [Str "Second"] ]
111111 , [ Para [Str "Third"] ] ]
112112, Para [Str "and",Space,Str "using",Space,Str "spaces:"]
113−, OrderedList
113+, OrderedList (1,DefaultStyle,DefaultDelim)
114114 [ [ Para [Str "One"] ]
115115 , [ Para [Str "Two"] ]
116116 , [ Para [Str "Three"] ] ]
117117, Para [Str "Multiple",Space,Str "paragraphs:"]
118−, OrderedList
118+, OrderedList (1,DefaultStyle,DefaultDelim)
119119 [ [ Para [Str "Item",Space,Str "1,",Space,Str "graf",Space,Str "one."]
120120 , Para [Str "Item",Space,Str "1.",Space,Str "graf",Space,Str "two.",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog's",Space,Str "back."] ], [ Para [Str "Item",Space,Str "2."] ]
121121 , [ Para [Str "Item",Space,Str "3."] ] ]
@@ -128,7 +128,7 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] [] "")
128128 [ [ Plain [Str "Tab"] ]
129129 ] ] ] ] ]
130130, Para [Str "Here's",Space,Str "another:"]
131−, OrderedList
131+, OrderedList (1,DefaultStyle,DefaultDelim)
132132 [ [ Plain [Str "First"] ]
133133 , [ Plain [Str "Second:"]
134134 , BulletList
@@ -136,7 +136,7 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] [] "")
136136 , [ Plain [Str "Fie"] ]
137137 , [ Plain [Str "Foe"] ] ] ], [ Plain [Str "Third"] ] ]
138138, Para [Str "Same",Space,Str "thing",Space,Str "but",Space,Str "with",Space,Str "paragraphs:"]
139−, OrderedList
139+, OrderedList (1,DefaultStyle,DefaultDelim)
140140 [ [ Para [Str "First"] ]
141141 , [ Para [Str "Second:"]
142142 , BulletList
@@ -150,6 +150,35 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] [] "")
150150 , BulletList
151151 [ [ Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"] ]
152152 , [ Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"] ] ] ] ]
153+, Header 2 [Str "Fancy",Space,Str "list",Space,Str "markers"]
154+, OrderedList (2,Decimal,DefaultDelim)
155+ [ [ Plain [Str "begins",Space,Str "with",Space,Str "2"] ]
156+ , [ Para [Str "and",Space,Str "now",Space,Str "3"]
157+ , Para [Str "with",Space,Str "a",Space,Str "continuation"]
158+ , OrderedList (4,LowerRoman,DefaultDelim)
159+ [ [ Plain [Str "sublist",Space,Str "with",Space,Str "roman",Space,Str "numerals,",Space,Str "starting",Space,Str "with",Space,Str "4"] ]
160+ , [ Plain [Str "more",Space,Str "items"]
161+ , OrderedList (1,UpperAlpha,DefaultDelim)
162+ [ [ Plain [Str "a",Space,Str "subsublist"] ]
163+ , [ Plain [Str "a",Space,Str "subsublist"] ] ] ] ] ] ]
164+, Para [Str "Nesting:"]
165+, OrderedList (1,UpperAlpha,DefaultDelim)
166+ [ [ Plain [Str "Upper",Space,Str "Alpha"]
167+ , OrderedList (1,UpperRoman,DefaultDelim)
168+ [ [ Plain [Str "Upper",Space,Str "Roman."]
169+ , OrderedList (6,Decimal,DefaultDelim)
170+ [ [ Plain [Str "Decimal",Space,Str "start",Space,Str "with",Space,Str "6"]
171+ , OrderedList (3,LowerAlpha,DefaultDelim)
172+ [ [ Plain [Str "Lower",Space,Str "alpha",Space,Str "with",Space,Str "paren"] ]
173+ ] ] ] ] ] ] ]
174+, Para [Str "Autonumbering:"]
175+, OrderedList (1,DefaultStyle,DefaultDelim)
176+ [ [ Plain [Str "Autonumber."] ]
177+ , [ Plain [Str "More."]
178+ , OrderedList (1,DefaultStyle,DefaultDelim)
179+ [ [ Plain [Str "Nested."] ]
180+ ] ] ]
181+, HorizontalRule
153182, Header 2 [Str "Definition"]
154183, DefinitionList
155184 [ ([Str "Violin"],
tests/rst-reader.native+35−7
@@ -27,7 +27,7 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite",Str ":",Space,Str
2727 , Para [Str "Code",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote",Str ":"]
2828 , CodeBlock "sub status {\n print \"working\";\n}"
2929 , Para [Str "List",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote",Str ":"]
30− , OrderedList
30+ , OrderedList (1,Decimal,Period)
3131 [ [ Plain [Str "item",Space,Str "one"] ]
3232 , [ Plain [Str "item",Space,Str "two"] ] ]
3333 , Para [Str "Nested",Space,Str "block",Space,Str "quotes",Str ":"]
@@ -76,27 +76,27 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite",Str ":",Space,Str
7676 , [ Para [Str "Minus",Space,Str "3"] ] ]
7777, Header 2 [Str "Ordered"]
7878, Para [Str "Tight",Str ":"]
79−, OrderedList
79+, OrderedList (1,Decimal,Period)
8080 [ [ Plain [Str "First"] ]
8181 , [ Plain [Str "Second"] ]
8282 , [ Plain [Str "Third"] ] ]
8383, Para [Str "and",Str ":"]
84−, OrderedList
84+, OrderedList (1,Decimal,Period)
8585 [ [ Plain [Str "One"] ]
8686 , [ Plain [Str "Two"] ]
8787 , [ Plain [Str "Three"] ] ]
8888, Para [Str "Loose",Space,Str "using",Space,Str "tabs",Str ":"]
89−, OrderedList
89+, OrderedList (1,Decimal,Period)
9090 [ [ Para [Str "First"] ]
9191 , [ Para [Str "Second"] ]
9292 , [ Para [Str "Third"] ] ]
9393, Para [Str "and",Space,Str "using",Space,Str "spaces",Str ":"]
94−, OrderedList
94+, OrderedList (1,Decimal,Period)
9595 [ [ Para [Str "One"] ]
9696 , [ Para [Str "Two"] ]
9797 , [ Para [Str "Three"] ] ]
9898, Para [Str "Multiple",Space,Str "paragraphs",Str ":"]
99−, OrderedList
99+, OrderedList (1,Decimal,Period)
100100 [ [ Para [Str "Item",Space,Str "1,",Space,Str "graf",Space,Str "one."]
101101 , Para [Str "Item",Space,Str "1.",Space,Str "graf",Space,Str "two.",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog's",Space,Str "back."] ], [ Para [Str "Item",Space,Str "2."] ]
102102 , [ Para [Str "Item",Space,Str "3."] ] ]
@@ -109,7 +109,7 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite",Str ":",Space,Str
109109 [ [ Plain [Str "Tab"] ]
110110 ] ] ] ] ]
111111, Para [Str "Here's",Space,Str "another",Str ":"]
112−, OrderedList
112+, OrderedList (1,Decimal,Period)
113113 [ [ Para [Str "First"] ]
114114 , [ Para [Str "Second",Str ":"]
115115 , BlockQuote
@@ -117,6 +117,34 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite",Str ":",Space,Str
117117 [ [ Plain [Str "Fee"] ]
118118 , [ Plain [Str "Fie"] ]
119119 , [ Plain [Str "Foe"] ] ] ] ], [ Para [Str "Third"] ] ]
120+, Header 2 [Str "Fancy",Space,Str "list",Space,Str "markers"]
121+, OrderedList (2,Decimal,TwoParens)
122+ [ [ Plain [Str "begins",Space,Str "with",Space,Str "2"] ]
123+ , [ Para [Str "and",Space,Str "now",Space,Str "3"]
124+ , Para [Str "with",Space,Str "a",Space,Str "continuation"]
125+ , OrderedList (4,LowerRoman,Period)
126+ [ [ Plain [Str "sublist",Space,Str "with",Space,Str "roman",Space,Str "numerals,",Space,Str "starting",Space,Str "with",Space,Str "4"] ]
127+ , [ Para [Str "more",Space,Str "items"]
128+ , OrderedList (1,UpperAlpha,TwoParens)
129+ [ [ Plain [Str "a",Space,Str "subsublist"] ]
130+ , [ Plain [Str "a",Space,Str "subsublist"] ] ] ] ] ] ]
131+, Para [Str "Nesting",Str ":"]
132+, OrderedList (1,UpperAlpha,Period)
133+ [ [ Para [Str "Upper",Space,Str "Alpha"]
134+ , OrderedList (1,UpperRoman,Period)
135+ [ [ Para [Str "Upper",Space,Str "Roman."]
136+ , OrderedList (6,Decimal,TwoParens)
137+ [ [ Para [Str "Decimal",Space,Str "start",Space,Str "with",Space,Str "6"]
138+ , OrderedList (3,LowerAlpha,OneParen)
139+ [ [ Plain [Str "Lower",Space,Str "alpha",Space,Str "with",Space,Str "paren"] ]
140+ ] ] ] ] ] ] ]
141+, Para [Str "Autonumbering",Str ":"]
142+, OrderedList (1,DefaultStyle,DefaultDelim)
143+ [ [ Plain [Str "Autonumber."] ]
144+ , [ Para [Str "More."]
145+ , OrderedList (1,DefaultStyle,DefaultDelim)
146+ [ [ Plain [Str "Nested."] ]
147+ ] ] ]
120148, Header 2 [Str "Definition"]
121149, DefinitionList
122150 [ ([Str "term",Space,Str "1"],
tests/rst-reader.rst+31
@@ -211,6 +211,37 @@ Here's another:
211211
2122123. Third
213213
214+Fancy list markers
215+------------------
216+
217+(2) begins with 2
218+(3) and now 3
219+
220+ with a continuation
221+
222+ iv. sublist with roman numerals, starting with 4
223+ v. more items
224+
225+ (A) a subsublist
226+ (B) a subsublist
227+
228+Nesting:
229+
230+A. Upper Alpha
231+
232+ I. Upper Roman.
233+
234+ (6) Decimal start with 6
235+
236+ c) Lower alpha with paren
237+
238+Autonumbering:
239+
240+#. Autonumber.
241+#. More.
242+
243+ #. Nested.
244+
214245Definition
215246----------
216247
tests/s5.basic.html+1−1
@@ -1,4 +1,4 @@
1−<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
1+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
22<html
33><head
44 ><title
tests/s5.fancy.html+1−1
@@ -1,4 +1,4 @@
1−<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
1+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
22<html
33><head
44 ><title
tests/s5.inserts.html+1−1
@@ -1,4 +1,4 @@
1−<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
1+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
22<html
33><head
44 ><title
tests/tables.rst−1
@@ -69,4 +69,3 @@ Multiline table without caption:
6969+-------------+------------+--------------+----------------------------+
7070
7171
72−
tests/testsuite.native+38−10
@@ -28,7 +28,7 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] ["John MacFarlane
2828 [ Para [Str "Code",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote:"]
2929 , CodeBlock "sub status {\n print \"working\";\n}"
3030 , Para [Str "A",Space,Str "list:"]
31− , OrderedList
31+ , OrderedList (1,Decimal,Period)
3232 [ [ Plain [Str "item",Space,Str "one"] ]
3333 , [ Plain [Str "item",Space,Str "two"] ] ]
3434 , Para [Str "Nested",Space,Str "block",Space,Str "quotes:"]
@@ -44,7 +44,7 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] ["John MacFarlane
4444 [ Para [Str "Example:"]
4545 , CodeBlock "sub status {\n print \"working\";\n}" ]
4646, BlockQuote
47− [ OrderedList
47+ [ OrderedList (1,Decimal,Period)
4848 [ [ Plain [Str "do",Space,Str "laundry"] ]
4949 , [ Plain [Str "take",Space,Str "out",Space,Str "the",Space,Str "trash"] ] ] ]
5050, Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "nested",Space,Str "one:"]
@@ -95,27 +95,27 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] ["John MacFarlane
9595 , [ Para [Str "Minus",Space,Str "3"] ] ]
9696, Header 2 [Str "Ordered"]
9797, Para [Str "Tight:"]
98−, OrderedList
98+, OrderedList (1,Decimal,Period)
9999 [ [ Plain [Str "First"] ]
100100 , [ Plain [Str "Second"] ]
101101 , [ Plain [Str "Third"] ] ]
102102, Para [Str "and:"]
103−, OrderedList
103+, OrderedList (1,Decimal,Period)
104104 [ [ Plain [Str "One"] ]
105105 , [ Plain [Str "Two"] ]
106106 , [ Plain [Str "Three"] ] ]
107107, Para [Str "Loose",Space,Str "using",Space,Str "tabs:"]
108−, OrderedList
108+, OrderedList (1,Decimal,Period)
109109 [ [ Para [Str "First"] ]
110110 , [ Para [Str "Second"] ]
111111 , [ Para [Str "Third"] ] ]
112112, Para [Str "and",Space,Str "using",Space,Str "spaces:"]
113−, OrderedList
113+, OrderedList (1,Decimal,Period)
114114 [ [ Para [Str "One"] ]
115115 , [ Para [Str "Two"] ]
116116 , [ Para [Str "Three"] ] ]
117117, Para [Str "Multiple",Space,Str "paragraphs:"]
118−, OrderedList
118+, OrderedList (1,Decimal,Period)
119119 [ [ Para [Str "Item",Space,Str "1,",Space,Str "graf",Space,Str "one",Str "."]
120120 , Para [Str "Item",Space,Str "1",Str ".",Space,Str "graf",Space,Str "two",Str ".",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog",Apostrophe,Str "s",Space,Str "back",Str "."] ], [ Para [Str "Item",Space,Str "2",Str "."] ]
121121 , [ Para [Str "Item",Space,Str "3",Str "."] ] ]
@@ -128,7 +128,7 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] ["John MacFarlane
128128 [ [ Plain [Str "Tab"] ]
129129 ] ] ] ] ]
130130, Para [Str "Here",Apostrophe,Str "s",Space,Str "another:"]
131−, OrderedList
131+, OrderedList (1,Decimal,Period)
132132 [ [ Plain [Str "First"] ]
133133 , [ Plain [Str "Second:"]
134134 , BulletList
@@ -136,7 +136,7 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] ["John MacFarlane
136136 , [ Plain [Str "Fie"] ]
137137 , [ Plain [Str "Foe"] ] ] ], [ Plain [Str "Third"] ] ]
138138, Para [Str "Same",Space,Str "thing",Space,Str "but",Space,Str "with",Space,Str "paragraphs:"]
139−, OrderedList
139+, OrderedList (1,Decimal,Period)
140140 [ [ Para [Str "First"] ]
141141 , [ Para [Str "Second:"]
142142 , BulletList
@@ -150,6 +150,34 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] ["John MacFarlane
150150 , BulletList
151151 [ [ Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"] ]
152152 , [ Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"] ] ] ] ]
153+, Header 2 [Str "Fancy",Space,Str "list",Space,Str "markers"]
154+, OrderedList (2,Decimal,TwoParens)
155+ [ [ Plain [Str "begins",Space,Str "with",Space,Str "2"] ]
156+ , [ Para [Str "and",Space,Str "now",Space,Str "3"]
157+ , Para [Str "with",Space,Str "a",Space,Str "continuation"]
158+ , OrderedList (4,LowerRoman,Period)
159+ [ [ Plain [Str "sublist",Space,Str "with",Space,Str "roman",Space,Str "numerals,",Space,Str "starting",Space,Str "with",Space,Str "4"] ]
160+ , [ Plain [Str "more",Space,Str "items"]
161+ , OrderedList (1,UpperAlpha,TwoParens)
162+ [ [ Plain [Str "a",Space,Str "subsublist"] ]
163+ , [ Plain [Str "a",Space,Str "subsublist"] ] ] ] ] ] ]
164+, Para [Str "Nesting:"]
165+, OrderedList (1,UpperAlpha,Period)
166+ [ [ Plain [Str "Upper",Space,Str "Alpha"]
167+ , OrderedList (1,UpperRoman,Period)
168+ [ [ Plain [Str "Upper",Space,Str "Roman",Str "."]
169+ , OrderedList (6,Decimal,TwoParens)
170+ [ [ Plain [Str "Decimal",Space,Str "start",Space,Str "with",Space,Str "6"]
171+ , OrderedList (3,LowerAlpha,OneParen)
172+ [ [ Plain [Str "Lower",Space,Str "alpha",Space,Str "with",Space,Str "paren"] ]
173+ ] ] ] ] ] ] ]
174+, Para [Str "Autonumbering:"]
175+, OrderedList (1,DefaultStyle,DefaultDelim)
176+ [ [ Plain [Str "Autonumber",Str "."] ]
177+ , [ Plain [Str "More",Str "."]
178+ , OrderedList (1,DefaultStyle,DefaultDelim)
179+ [ [ Plain [Str "Nested",Str "."] ]
180+ ] ] ]
153181, HorizontalRule
154182, Header 1 [Str "Definition",Space,Str "Lists"]
155183, Para [Str "Tight",Space,Str "using",Space,Str "spaces:"]
@@ -363,7 +391,7 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] ["John MacFarlane
363391, BlockQuote
364392 [ Para [Str "Notes",Space,Str "can",Space,Str "go",Space,Str "in",Space,Str "quotes",Str ".",Note [Para [Str "In",Space,Str "quote",Str "."]]] ]
365393
366−, OrderedList
394+, OrderedList (1,Decimal,Period)
367395 [ [ Plain [Str "And",Space,Str "in",Space,Str "list",Space,Str "items",Str ".",Note [Para [Str "In",Space,Str "list",Str "."]]] ]
368396 ]
369397, Para [Str "This",Space,Str "paragraph",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "part",Space,Str "of",Space,Str "the",Space,Str "note,",Space,Str "as",Space,Str "it",Space,Str "is",Space,Str "not",Space,Str "indented",Str "."] ]
tests/testsuite.txt+26
@@ -255,6 +255,32 @@ Same thing but with paragraphs:
255255 + this is an example list item
256256 indented with spaces
257257
258+## Fancy list markers
259+
260+(2) begins with 2
261+(3) and now 3
262+
263+ with a continuation
264+
265+ iv. sublist with roman numerals,
266+ starting with 4
267+ v. more items
268+ (A) a subsublist
269+ (B) a subsublist
270+
271+Nesting:
272+
273+A. Upper Alpha
274+ I. Upper Roman.
275+ (6) Decimal start with 6
276+ c) Lower alpha with paren
277+
278+Autonumbering:
279+
280+ #. Autonumber.
281+ #. More.
282+ #. Nested.
283+
258284 * * * * *
259285
260286# Definition Lists
tests/writer.context+86−46
@@ -127,10 +127,10 @@ sub status {
127127\stoptyping
128128A list:
129129
130−\startltxenum
131−\item item one
132−\item item two
133−\stopltxenum
130+\startitemize
131+\sym{1.} item one
132+\sym{2.} item two
133+\stopitemize
134134Nested block quotes:
135135
136136\startblockquote
@@ -160,10 +160,10 @@ sub status {
160160\stopblockquote
161161
162162\startblockquote
163−\startltxenum
164−\item do laundry
165−\item take out the trash
166−\stopltxenum
163+\startitemize
164+\sym{1.} do laundry
165+\sym{2.} take out the trash
166+\stopitemize
167167\stopblockquote
168168
169169Here's a nested one:
@@ -263,50 +263,50 @@ Minuses loose:
263263
264264Tight:
265265
266−\startltxenum
267−\item First
268−\item Second
269−\item Third
270−\stopltxenum
266+\startitemize
267+\sym{1.} First
268+\sym{2.} Second
269+\sym{3.} Third
270+\stopitemize
271271and:
272272
273−\startltxenum
274−\item One
275−\item Two
276−\item Three
277−\stopltxenum
273+\startitemize
274+\sym{1.} One
275+\sym{2.} Two
276+\sym{3.} Three
277+\stopitemize
278278Loose using tabs:
279279
280−\startltxenum
281−\item First
280+\startitemize
281+\sym{1.} First
282282
283−\item Second
283+\sym{2.} Second
284284
285−\item Third
285+\sym{3.} Third
286286
287−\stopltxenum
287+\stopitemize
288288and using spaces:
289289
290−\startltxenum
291−\item One
290+\startitemize
291+\sym{1.} One
292292
293−\item Two
293+\sym{2.} Two
294294
295−\item Three
295+\sym{3.} Three
296296
297−\stopltxenum
297+\stopitemize
298298Multiple paragraphs:
299299
300−\startltxenum
301−\item Item 1, graf one.
300+\startitemize
301+\sym{1.} Item 1, graf one.
302302
303303Item 1. graf two. The quick brown fox jumped over the lazy dog's back.
304304
305−\item Item 2.
305+\sym{2.} Item 2.
306306
307−\item Item 3.
307+\sym{3.} Item 3.
308308
309−\stopltxenum
309+\stopitemize
310310\subsection{Nested}
311311
312312\startltxitem
@@ -320,31 +320,31 @@ Item 1. graf two. The quick brown fox jumped over the lazy dog's back.
320320\stopltxitem
321321Here's another:
322322
323−\startltxenum
324−\item First
325−\item Second:
323+\startitemize
324+\sym{1.} First
325+\sym{2.} Second:
326326\startltxitem
327327\item Fee
328328\item Fie
329329\item Foe
330330\stopltxitem
331−\item Third
332−\stopltxenum
331+\sym{3.} Third
332+\stopitemize
333333Same thing but with paragraphs:
334334
335−\startltxenum
336−\item First
335+\startitemize
336+\sym{1.} First
337337
338−\item Second:
338+\sym{2.} Second:
339339
340340\startltxitem
341341\item Fee
342342\item Fie
343343\item Foe
344344\stopltxitem
345−\item Third
345+\sym{3.} Third
346346
347−\stopltxenum
347+\stopitemize
348348\subsection{Tabs and spaces}
349349
350350\startltxitem
@@ -359,6 +359,46 @@ Same thing but with paragraphs:
359359
360360\stopltxitem
361361\stopltxitem
362+\subsection{Fancy list markers}
363+
364+\startitemize[width=2em]
365+\sym{(2)} begins with 2
366+\sym{(3)} and now 3
367+
368+with a continuation
369+
370+\startitemize[width=2em]
371+\sym{iv.} sublist with roman numerals, starting with 4
372+\sym{v.} more items
373+\startitemize[width=2em]
374+\sym{(A)} a subsublist
375+\sym{(B)} a subsublist
376+\stopitemize
377+\stopitemize
378+\stopitemize
379+Nesting:
380+
381+\startitemize
382+\sym{A.} Upper Alpha
383+\startitemize
384+\sym{I.} Upper Roman.
385+\startitemize[width=2em]
386+\sym{(6)} Decimal start with 6
387+\startitemize
388+\sym{c)} Lower alpha with paren
389+\stopitemize
390+\stopitemize
391+\stopitemize
392+\stopitemize
393+Autonumbering:
394+
395+\startltxenum
396+\item Autonumber.
397+\item More.
398+\startltxenum
399+\item Nested.
400+\stopltxenum
401+\stopltxenum
362402\thinrule
363403
364404\section{Definition Lists}
@@ -712,11 +752,11 @@ Notes can go in quotes.\footnote{In quote.
712752
713753\stopblockquote
714754
715−\startltxenum
716−\item And in list items.\footnote{In list.
755+\startitemize
756+\sym{1.} And in list items.\footnote{In list.
717757
718758}
719−\stopltxenum
759+\stopitemize
720760This paragraph should not be part of the note, as it is not indented.
721761
722762
tests/writer.docbook+105−10
@@ -95,7 +95,7 @@ sub status {
9595 <para>
9696 A list:
9797 </para>
98− <orderedlist>
98+ <orderedlist numeration="arabic">
9999 <listitem>
100100 <para>
101101 item one
@@ -138,7 +138,7 @@ sub status {
138138</screen>
139139 </blockquote>
140140 <blockquote>
141− <orderedlist>
141+ <orderedlist numeration="arabic">
142142 <listitem>
143143 <para>
144144 do laundry
@@ -321,7 +321,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
321321 <para>
322322 Tight:
323323 </para>
324− <orderedlist>
324+ <orderedlist numeration="arabic">
325325 <listitem>
326326 <para>
327327 First
@@ -341,7 +341,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
341341 <para>
342342 and:
343343 </para>
344− <orderedlist>
344+ <orderedlist numeration="arabic">
345345 <listitem>
346346 <para>
347347 One
@@ -361,7 +361,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
361361 <para>
362362 Loose using tabs:
363363 </para>
364− <orderedlist>
364+ <orderedlist numeration="arabic">
365365 <listitem>
366366 <para>
367367 First
@@ -381,7 +381,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
381381 <para>
382382 and using spaces:
383383 </para>
384− <orderedlist>
384+ <orderedlist numeration="arabic">
385385 <listitem>
386386 <para>
387387 One
@@ -401,7 +401,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
401401 <para>
402402 Multiple paragraphs:
403403 </para>
404− <orderedlist>
404+ <orderedlist numeration="arabic">
405405 <listitem>
406406 <para>
407407 Item 1, graf one.
@@ -449,7 +449,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
449449 <para>
450450 Here's another:
451451 </para>
452− <orderedlist>
452+ <orderedlist numeration="arabic">
453453 <listitem>
454454 <para>
455455 First
@@ -486,7 +486,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
486486 <para>
487487 Same thing but with paragraphs:
488488 </para>
489− <orderedlist>
489+ <orderedlist numeration="arabic">
490490 <listitem>
491491 <para>
492492 First
@@ -548,6 +548,101 @@ These should not be escaped: \$ \\ \&gt; \[ \{
548548 </listitem>
549549 </itemizedlist>
550550 </section>
551+ <section>
552+ <title>Fancy list markers</title>
553+ <orderedlist numeration="arabic">
554+ <listitem override="2">
555+ <para>
556+ begins with 2
557+ </para>
558+ </listitem>
559+ <listitem>
560+ <para>
561+ and now 3
562+ </para>
563+ <para>
564+ with a continuation
565+ </para>
566+ <orderedlist numeration="lowerroman">
567+ <listitem override="4">
568+ <para>
569+ sublist with roman numerals, starting with 4
570+ </para>
571+ </listitem>
572+ <listitem>
573+ <para>
574+ more items
575+ </para>
576+ <orderedlist numeration="upperalpha">
577+ <listitem>
578+ <para>
579+ a subsublist
580+ </para>
581+ </listitem>
582+ <listitem>
583+ <para>
584+ a subsublist
585+ </para>
586+ </listitem>
587+ </orderedlist>
588+ </listitem>
589+ </orderedlist>
590+ </listitem>
591+ </orderedlist>
592+ <para>
593+ Nesting:
594+ </para>
595+ <orderedlist numeration="upperalpha">
596+ <listitem>
597+ <para>
598+ Upper Alpha
599+ </para>
600+ <orderedlist numeration="upperroman">
601+ <listitem>
602+ <para>
603+ Upper Roman.
604+ </para>
605+ <orderedlist numeration="arabic">
606+ <listitem override="6">
607+ <para>
608+ Decimal start with 6
609+ </para>
610+ <orderedlist numeration="loweralpha">
611+ <listitem override="3">
612+ <para>
613+ Lower alpha with paren
614+ </para>
615+ </listitem>
616+ </orderedlist>
617+ </listitem>
618+ </orderedlist>
619+ </listitem>
620+ </orderedlist>
621+ </listitem>
622+ </orderedlist>
623+ <para>
624+ Autonumbering:
625+ </para>
626+ <orderedlist>
627+ <listitem>
628+ <para>
629+ Autonumber.
630+ </para>
631+ </listitem>
632+ <listitem>
633+ <para>
634+ More.
635+ </para>
636+ <orderedlist>
637+ <listitem>
638+ <para>
639+ Nested.
640+ </para>
641+ </listitem>
642+ </orderedlist>
643+ </listitem>
644+ </orderedlist>
645+ </section>
551646 </section>
552647 <section>
553648 <title>Definition Lists</title>
@@ -1158,7 +1253,7 @@ or here: &lt;http://example.com/&gt;
11581253 </footnote>
11591254 </para>
11601255 </blockquote>
1161− <orderedlist>
1256+ <orderedlist numeration="arabic">
11621257 <listitem>
11631258 <para>
11641259 And in list
tests/writer.html+73−12
@@ -1,4 +1,4 @@
1−<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
1+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
22<html
33><head
44 ><title
@@ -9,7 +9,14 @@
99 /><meta name="author" content="Anonymous"
1010 /><meta name="date" content="July 17, 2006"
1111 /><style type="text/css"
12− >.strikeout { text-decoration: line-through; }</style
12+ >
13+.strikeout { text-decoration: line-through; }
14+ol.decimal { list-style-type: decimal; }
15+ol.lower-alpha { list-style-type: lower-alpha; }
16+ol.lower-roman { list-style-type: lower-roman; }
17+ol.upper-alpha { list-style-type: upper-alpha; }
18+ol.upper-roman { list-style-type: upper-roman; }
19+</style
1320 ></head
1421 ><body
1522 ><h1 class="title"
@@ -78,7 +85,7 @@
7885 ></pre
7986 ><p
8087 >A list:</p
81− ><ol
88+ ><ol class="decimal"
8289 ><li
8390 >item one</li
8491 ><li
@@ -111,7 +118,7 @@
111118 ></pre
112119 ></blockquote
113120 ><blockquote
114− ><ol
121+ ><ol class="decimal"
115122 ><li
116123 >do laundry</li
117124 ><li
@@ -242,7 +249,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
242249 >Ordered</h2
243250 ><p
244251 >Tight:</p
245− ><ol
252+ ><ol class="decimal"
246253 ><li
247254 >First</li
248255 ><li
@@ -252,7 +259,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
252259 ></ol
253260 ><p
254261 >and:</p
255− ><ol
262+ ><ol class="decimal"
256263 ><li
257264 >One</li
258265 ><li
@@ -262,7 +269,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
262269 ></ol
263270 ><p
264271 >Loose using tabs:</p
265− ><ol
272+ ><ol class="decimal"
266273 ><li
267274 ><p
268275 >First</p
@@ -278,7 +285,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
278285 ></ol
279286 ><p
280287 >and using spaces:</p
281− ><ol
288+ ><ol class="decimal"
282289 ><li
283290 ><p
284291 >One</p
@@ -294,7 +301,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
294301 ></ol
295302 ><p
296303 >Multiple paragraphs:</p
297− ><ol
304+ ><ol class="decimal"
298305 ><li
299306 ><p
300307 >Item 1, graf one.</p
@@ -326,7 +333,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
326333 ></ul
327334 ><p
328335 >Here&rsquo;s another:</p
329− ><ol
336+ ><ol class="decimal"
330337 ><li
331338 >First</li
332339 ><li
@@ -344,7 +351,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
344351 ></ol
345352 ><p
346353 >Same thing but with paragraphs:</p
347− ><ol
354+ ><ol class="decimal"
348355 ><li
349356 ><p
350357 >First</p
@@ -388,6 +395,60 @@ These should not be escaped: \$ \\ \&gt; \[ \{
388395 ></ul
389396 ></li
390397 ></ul
398+ ><h2 id="fancy-list-markers"
399+ >Fancy list markers</h2
400+ ><ol start="2" class="decimal"
401+ ><li
402+ >begins with 2</li
403+ ><li
404+ ><p
405+ >and now 3</p
406+ ><p
407+ >with a continuation</p
408+ ><ol start="4" class="lower-roman"
409+ ><li
410+ >sublist with roman numerals, starting with 4</li
411+ ><li
412+ >more items<ol class="upper-alpha"
413+ ><li
414+ >a subsublist</li
415+ ><li
416+ >a subsublist</li
417+ ></ol
418+ ></li
419+ ></ol
420+ ></li
421+ ></ol
422+ ><p
423+ >Nesting:</p
424+ ><ol class="upper-alpha"
425+ ><li
426+ >Upper Alpha<ol class="upper-roman"
427+ ><li
428+ >Upper Roman.<ol start="6" class="decimal"
429+ ><li
430+ >Decimal start with 6<ol start="3" class="lower-alpha"
431+ ><li
432+ >Lower alpha with paren</li
433+ ></ol
434+ ></li
435+ ></ol
436+ ></li
437+ ></ol
438+ ></li
439+ ></ol
440+ ><p
441+ >Autonumbering:</p
442+ ><ol
443+ ><li
444+ >Autonumber.</li
445+ ><li
446+ >More.<ol
447+ ><li
448+ >Nested.</li
449+ ></ol
450+ ></li
451+ ></ol
391452 ><hr
392453 /><h1 id="definition-lists"
393454 >Definition Lists</h1
@@ -995,7 +1056,7 @@ document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'">'+'<code>'+e+'</code>'+'<\/'+
9951056 ></a
9961057 ></p
9971058 ></blockquote
998− ><ol
1059+ ><ol class="decimal"
9991060 ><li
10001061 >And in list items.<a href="#fn5" class="footnoteRef" id="fnref5"
10011062 ><sup
tests/writer.latex+56−11
@@ -1,11 +1,12 @@
11\documentclass{article}
2−\usepackage{ucs}
2+\usepackage[mathletters]{ucs}
33\usepackage[utf8x]{inputenc}
44\setlength{\parindent}{0pt}
55\setlength{\parskip}{6pt plus 2pt minus 1pt}
66\newcommand{\textsubscript}[1]{\ensuremath{_{\scriptsize\textrm{#1}}}}
77\usepackage[breaklinks=true]{hyperref}
88\usepackage[normalem]{ulem}
9+\usepackage{enumerate}
910\usepackage{fancyvrb}
1011\usepackage{graphicx}
1112\setcounter{secnumdepth}{0}
@@ -75,7 +76,7 @@ sub status {
7576\end{verbatim}
7677A list:
7778
78−\begin{enumerate}
79+\begin{enumerate}[1.]
7980\item item one
8081\item item two
8182\end{enumerate}
@@ -104,7 +105,7 @@ sub status {
104105\end{verbatim}
105106\end{quote}
106107\begin{quote}
107−\begin{enumerate}
108+\begin{enumerate}[1.]
108109\item do laundry
109110\item take out the trash
110111\end{enumerate}
@@ -204,21 +205,21 @@ Minuses loose:
204205
205206Tight:
206207
207−\begin{enumerate}
208+\begin{enumerate}[1.]
208209\item First
209210\item Second
210211\item Third
211212\end{enumerate}
212213and:
213214
214−\begin{enumerate}
215+\begin{enumerate}[1.]
215216\item One
216217\item Two
217218\item Three
218219\end{enumerate}
219220Loose using tabs:
220221
221−\begin{enumerate}
222+\begin{enumerate}[1.]
222223\item First
223224
224225\item Second
@@ -228,7 +229,7 @@ Loose using tabs:
228229\end{enumerate}
229230and using spaces:
230231
231−\begin{enumerate}
232+\begin{enumerate}[1.]
232233\item One
233234
234235\item Two
@@ -238,7 +239,7 @@ and using spaces:
238239\end{enumerate}
239240Multiple paragraphs:
240241
241−\begin{enumerate}
242+\begin{enumerate}[1.]
242243\item Item 1, graf one.
243244
244245Item 1. graf two. The quick brown fox jumped over the lazy dog's back.
@@ -261,7 +262,7 @@ Item 1. graf two. The quick brown fox jumped over the lazy dog's back.
261262\end{itemize}
262263Here's another:
263264
264−\begin{enumerate}
265+\begin{enumerate}[1.]
265266\item First
266267\item Second:
267268\begin{itemize}
@@ -273,7 +274,7 @@ Here's another:
273274\end{enumerate}
274275Same thing but with paragraphs:
275276
276−\begin{enumerate}
277+\begin{enumerate}[1.]
277278\item First
278279
279280\item Second:
@@ -300,6 +301,50 @@ Same thing but with paragraphs:
300301
301302\end{itemize}
302303\end{itemize}
304+\subsection{Fancy list markers}
305+
306+\begin{enumerate}[(1)]
307+\setcounter{enumi}{1}
308+\item begins with 2
309+\item and now 3
310+
311+with a continuation
312+
313+\begin{enumerate}[i.]
314+\setcounter{enumii}{3}
315+\item sublist with roman numerals, starting with 4
316+\item more items
317+\begin{enumerate}[(A)]
318+\item a subsublist
319+\item a subsublist
320+\end{enumerate}
321+\end{enumerate}
322+\end{enumerate}
323+Nesting:
324+
325+\begin{enumerate}[A.]
326+\item Upper Alpha
327+\begin{enumerate}[I.]
328+\item Upper Roman.
329+\begin{enumerate}[(1)]
330+\setcounter{enumiii}{5}
331+\item Decimal start with 6
332+\begin{enumerate}[a)]
333+\setcounter{enumiv}{2}
334+\item Lower alpha with paren
335+\end{enumerate}
336+\end{enumerate}
337+\end{enumerate}
338+\end{enumerate}
339+Autonumbering:
340+
341+\begin{enumerate}
342+\item Autonumber.
343+\item More.
344+\begin{enumerate}
345+\item Nested.
346+\end{enumerate}
347+\end{enumerate}
303348\begin{center}\rule{3in}{0.4pt}\end{center}
304349
305350\section{Definition Lists}
@@ -635,7 +680,7 @@ If you want, you can indent every line, but you can also be lazy and just indent
635680Notes can go in quotes.\footnote{In quote.}
636681
637682\end{quote}
638−\begin{enumerate}
683+\begin{enumerate}[1.]
639684\item And in list items.\footnote{In list.}
640685\end{enumerate}
641686This paragraph should not be part of the note, as it is not indented.
tests/writer.man+71−26
@@ -54,9 +54,9 @@ Code in a block quote:
5454\f[]
5555.PP
5656A list:
57−.IP 1. 4
57+.IP "1." 3
5858item one
59−.IP 2. 4
59+.IP "2." 3
6060item two
6161.PP
6262Nested block quotes:
@@ -84,9 +84,9 @@ Example:
8484\f[]
8585.RE
8686.RS
87−.IP 1. 4
87+.IP "1." 3
8888do laundry
89−.IP 2. 4
89+.IP "2." 3
9090take out the trash
9191.RE
9292.PP
@@ -179,48 +179,48 @@ Minus 3
179179.SS Ordered
180180.PP
181181Tight:
182−.IP 1. 4
182+.IP "1." 3
183183First
184−.IP 2. 4
184+.IP "2." 3
185185Second
186−.IP 3. 4
186+.IP "3." 3
187187Third
188188.PP
189189and:
190−.IP 1. 4
190+.IP "1." 3
191191One
192−.IP 2. 4
192+.IP "2." 3
193193Two
194−.IP 3. 4
194+.IP "3." 3
195195Three
196196.PP
197197Loose using tabs:
198−.IP 1. 4
198+.IP "1." 3
199199First
200−.IP 2. 4
200+.IP "2." 3
201201Second
202−.IP 3. 4
202+.IP "3." 3
203203Third
204204.PP
205205and using spaces:
206−.IP 1. 4
206+.IP "1." 3
207207One
208−.IP 2. 4
208+.IP "2." 3
209209Two
210−.IP 3. 4
210+.IP "3." 3
211211Three
212212.PP
213213Multiple paragraphs:
214−.IP 1. 4
214+.IP "1." 3
215215Item 1, graf one\.
216216.RS 4
217217.PP
218218Item 1\. graf two\. The quick brown fox jumped over the lazy dog's
219219back\.
220220.RE
221−.IP 2. 4
221+.IP "2." 3
222222Item 2\.
223−.IP 3. 4
223+.IP "3." 3
224224Item 3\.
225225.SS Nested
226226.IP \[bu] 2
@@ -235,9 +235,9 @@ Tab
235235.RE
236236.PP
237237Here's another:
238−.IP 1. 4
238+.IP "1." 3
239239First
240−.IP 2. 4
240+.IP "2." 3
241241Second:
242242.RS 4
243243.IP \[bu] 2
@@ -247,13 +247,13 @@ Fie
247247.IP \[bu] 2
248248Foe
249249.RE
250−.IP 3. 4
250+.IP "3." 3
251251Third
252252.PP
253253Same thing but with paragraphs:
254−.IP 1. 4
254+.IP "1." 3
255255First
256−.IP 2. 4
256+.IP "2." 3
257257Second:
258258.RS 4
259259.IP \[bu] 2
@@ -263,7 +263,7 @@ Fie
263263.IP \[bu] 2
264264Foe
265265.RE
266−.IP 3. 4
266+.IP "3." 3
267267Third
268268.SS Tabs and spaces
269269.IP \[bu] 2
@@ -276,6 +276,51 @@ this is an example list item indented with tabs
276276.IP \[bu] 2
277277this is an example list item indented with spaces
278278.RE
279+.SS Fancy list markers
280+.IP "(2)" 4
281+begins with 2
282+.IP "(3)" 4
283+and now 3
284+.RS 4
285+.PP
286+with a continuation
287+.IP "iv." 4
288+sublist with roman numerals, starting with 4
289+.IP " v." 4
290+more items
291+.RS 4
292+.IP "(A)" 4
293+a subsublist
294+.IP "(B)" 4
295+a subsublist
296+.RE
297+.RE
298+.PP
299+Nesting:
300+.IP "A." 3
301+Upper Alpha
302+.RS 4
303+.IP "I." 3
304+Upper Roman\.
305+.RS 4
306+.IP "(6)" 4
307+Decimal start with 6
308+.RS 4
309+.IP "c)" 3
310+Lower alpha with paren
311+.RE
312+.RE
313+.RE
314+.PP
315+Autonumbering:
316+.IP "1." 3
317+Autonumber\.
318+.IP "2." 3
319+More\.
320+.RS 4
321+.IP "1." 3
322+Nested\.
323+.RE
279324.PP
280325 * * * * *
281326.SH Definition Lists
@@ -716,7 +761,7 @@ space\.[^my note] Here is an inline note\.[3]
716761.PP
717762Notes can go in quotes\.[4]
718763.RE
719−.IP 1. 4
764+.IP "1." 3
720765And in list items\.[5]
721766.PP
722767This paragraph should not be part of the note, as it is not
tests/writer.markdown+31
@@ -253,6 +253,37 @@ Same thing but with paragraphs:
253253
254254
255255
256+## Fancy list markers
257+
258+(2) begins with 2
259+(3) and now 3
260+
261+ with a continuation
262+
263+ iv. sublist with roman numerals, starting with 4
264+ v. more items
265+ (A) a subsublist
266+ (B) a subsublist
267+
268+
269+
270+Nesting:
271+
272+A. Upper Alpha
273+ I. Upper Roman.
274+ (6) Decimal start with 6
275+ c) Lower alpha with paren
276+
277+
278+
279+
280+Autonumbering:
281+
282+1. Autonumber.
283+2. More.
284+ 1. Nested.
285+
286+
256287
257288* * * * *
258289
tests/writer.native+38−10
@@ -28,7 +28,7 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] ["John MacFarlane
2828 [ Para [Str "Code",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote:"]
2929 , CodeBlock "sub status {\n print \"working\";\n}"
3030 , Para [Str "A",Space,Str "list:"]
31− , OrderedList
31+ , OrderedList (1,Decimal,Period)
3232 [ [ Plain [Str "item",Space,Str "one"] ]
3333 , [ Plain [Str "item",Space,Str "two"] ] ]
3434 , Para [Str "Nested",Space,Str "block",Space,Str "quotes:"]
@@ -44,7 +44,7 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] ["John MacFarlane
4444 [ Para [Str "Example:"]
4545 , CodeBlock "sub status {\n print \"working\";\n}" ]
4646, BlockQuote
47− [ OrderedList
47+ [ OrderedList (1,Decimal,Period)
4848 [ [ Plain [Str "do",Space,Str "laundry"] ]
4949 , [ Plain [Str "take",Space,Str "out",Space,Str "the",Space,Str "trash"] ] ] ]
5050, Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "nested",Space,Str "one:"]
@@ -95,27 +95,27 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] ["John MacFarlane
9595 , [ Para [Str "Minus",Space,Str "3"] ] ]
9696, Header 2 [Str "Ordered"]
9797, Para [Str "Tight:"]
98−, OrderedList
98+, OrderedList (1,Decimal,Period)
9999 [ [ Plain [Str "First"] ]
100100 , [ Plain [Str "Second"] ]
101101 , [ Plain [Str "Third"] ] ]
102102, Para [Str "and:"]
103−, OrderedList
103+, OrderedList (1,Decimal,Period)
104104 [ [ Plain [Str "One"] ]
105105 , [ Plain [Str "Two"] ]
106106 , [ Plain [Str "Three"] ] ]
107107, Para [Str "Loose",Space,Str "using",Space,Str "tabs:"]
108−, OrderedList
108+, OrderedList (1,Decimal,Period)
109109 [ [ Para [Str "First"] ]
110110 , [ Para [Str "Second"] ]
111111 , [ Para [Str "Third"] ] ]
112112, Para [Str "and",Space,Str "using",Space,Str "spaces:"]
113−, OrderedList
113+, OrderedList (1,Decimal,Period)
114114 [ [ Para [Str "One"] ]
115115 , [ Para [Str "Two"] ]
116116 , [ Para [Str "Three"] ] ]
117117, Para [Str "Multiple",Space,Str "paragraphs:"]
118−, OrderedList
118+, OrderedList (1,Decimal,Period)
119119 [ [ Para [Str "Item",Space,Str "1,",Space,Str "graf",Space,Str "one",Str "."]
120120 , Para [Str "Item",Space,Str "1",Str ".",Space,Str "graf",Space,Str "two",Str ".",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog",Apostrophe,Str "s",Space,Str "back",Str "."] ], [ Para [Str "Item",Space,Str "2",Str "."] ]
121121 , [ Para [Str "Item",Space,Str "3",Str "."] ] ]
@@ -128,7 +128,7 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] ["John MacFarlane
128128 [ [ Plain [Str "Tab"] ]
129129 ] ] ] ] ]
130130, Para [Str "Here",Apostrophe,Str "s",Space,Str "another:"]
131−, OrderedList
131+, OrderedList (1,Decimal,Period)
132132 [ [ Plain [Str "First"] ]
133133 , [ Plain [Str "Second:"]
134134 , BulletList
@@ -136,7 +136,7 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] ["John MacFarlane
136136 , [ Plain [Str "Fie"] ]
137137 , [ Plain [Str "Foe"] ] ] ], [ Plain [Str "Third"] ] ]
138138, Para [Str "Same",Space,Str "thing",Space,Str "but",Space,Str "with",Space,Str "paragraphs:"]
139−, OrderedList
139+, OrderedList (1,Decimal,Period)
140140 [ [ Para [Str "First"] ]
141141 , [ Para [Str "Second:"]
142142 , BulletList
@@ -150,6 +150,34 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] ["John MacFarlane
150150 , BulletList
151151 [ [ Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"] ]
152152 , [ Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"] ] ] ] ]
153+, Header 2 [Str "Fancy",Space,Str "list",Space,Str "markers"]
154+, OrderedList (2,Decimal,TwoParens)
155+ [ [ Plain [Str "begins",Space,Str "with",Space,Str "2"] ]
156+ , [ Para [Str "and",Space,Str "now",Space,Str "3"]
157+ , Para [Str "with",Space,Str "a",Space,Str "continuation"]
158+ , OrderedList (4,LowerRoman,Period)
159+ [ [ Plain [Str "sublist",Space,Str "with",Space,Str "roman",Space,Str "numerals,",Space,Str "starting",Space,Str "with",Space,Str "4"] ]
160+ , [ Plain [Str "more",Space,Str "items"]
161+ , OrderedList (1,UpperAlpha,TwoParens)
162+ [ [ Plain [Str "a",Space,Str "subsublist"] ]
163+ , [ Plain [Str "a",Space,Str "subsublist"] ] ] ] ] ] ]
164+, Para [Str "Nesting:"]
165+, OrderedList (1,UpperAlpha,Period)
166+ [ [ Plain [Str "Upper",Space,Str "Alpha"]
167+ , OrderedList (1,UpperRoman,Period)
168+ [ [ Plain [Str "Upper",Space,Str "Roman",Str "."]
169+ , OrderedList (6,Decimal,TwoParens)
170+ [ [ Plain [Str "Decimal",Space,Str "start",Space,Str "with",Space,Str "6"]
171+ , OrderedList (3,LowerAlpha,OneParen)
172+ [ [ Plain [Str "Lower",Space,Str "alpha",Space,Str "with",Space,Str "paren"] ]
173+ ] ] ] ] ] ] ]
174+, Para [Str "Autonumbering:"]
175+, OrderedList (1,DefaultStyle,DefaultDelim)
176+ [ [ Plain [Str "Autonumber",Str "."] ]
177+ , [ Plain [Str "More",Str "."]
178+ , OrderedList (1,DefaultStyle,DefaultDelim)
179+ [ [ Plain [Str "Nested",Str "."] ]
180+ ] ] ]
153181, HorizontalRule
154182, Header 1 [Str "Definition",Space,Str "Lists"]
155183, Para [Str "Tight",Space,Str "using",Space,Str "spaces:"]
@@ -363,7 +391,7 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] ["John MacFarlane
363391, BlockQuote
364392 [ Para [Str "Notes",Space,Str "can",Space,Str "go",Space,Str "in",Space,Str "quotes",Str ".",Note [Para [Str "In",Space,Str "quote",Str "."]]] ]
365393
366−, OrderedList
394+, OrderedList (1,Decimal,Period)
367395 [ [ Plain [Str "And",Space,Str "in",Space,Str "list",Space,Str "items",Str ".",Note [Para [Str "In",Space,Str "list",Str "."]]] ]
368396 ]
369397, Para [Str "This",Space,Str "paragraph",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "part",Space,Str "of",Space,Str "the",Space,Str "note,",Space,Str "as",Space,Str "it",Space,Str "is",Space,Str "not",Space,Str "indented",Str "."] ]
tests/writer.rst+91−23
@@ -78,8 +78,9 @@ E-mail style:
7878
7979 A list:
8080
81− 1. item one
82− 2. item two
81+
82+ 1. item one
83+ 2. item two
8384
8485 Nested block quotes:
8586
@@ -103,8 +104,9 @@ Box-style:
103104 }
104105
105106
106− 1. do laundry
107− 2. take out the trash
107+
108+ 1. do laundry
109+ 2. take out the trash
108110
109111
110112Here's a nested one:
@@ -152,12 +154,14 @@ Unordered
152154
153155Asterisks tight:
154156
157+
155158- asterisk 1
156159- asterisk 2
157160- asterisk 3
158161
159162Asterisks loose:
160163
164+
161165- asterisk 1
162166
163167- asterisk 2
@@ -167,12 +171,14 @@ Asterisks loose:
167171
168172Pluses tight:
169173
174+
170175- Plus 1
171176- Plus 2
172177- Plus 3
173178
174179Pluses loose:
175180
181+
176182- Plus 1
177183
178184- Plus 2
@@ -182,12 +188,14 @@ Pluses loose:
182188
183189Minuses tight:
184190
191+
185192- Minus 1
186193- Minus 2
187194- Minus 3
188195
189196Minuses loose:
190197
198+
191199- Minus 1
192200
193201- Minus 2
@@ -200,91 +208,146 @@ Ordered
200208
201209Tight:
202210
203−1. First
204−2. Second
205−3. Third
211+
212+1. First
213+2. Second
214+3. Third
206215
207216and:
208217
209−1. One
210−2. Two
211−3. Three
218+
219+1. One
220+2. Two
221+3. Three
212222
213223Loose using tabs:
214224
215−1. First
216225
217−2. Second
226+1. First
227+
228+2. Second
218229
219−3. Third
230+3. Third
220231
221232
222233and using spaces:
223234
224−1. One
225235
226−2. Two
236+1. One
237+
238+2. Two
227239
228−3. Three
240+3. Three
229241
230242
231243Multiple paragraphs:
232244
245+
2332461. Item 1, graf one.
234247
235248 Item 1. graf two. The quick brown fox jumped over the lazy dog's
236249 back.
237250
238−2. Item 2.
251+2. Item 2.
239252
240−3. Item 3.
253+3. Item 3.
241254
242255
243256Nested
244257------
245258
259+
246260- Tab
261+
247262 - Tab
263+
248264 - Tab
249265
250266
251267
252268Here's another:
253269
254−1. First
270+
271+1. First
2552722. Second:
273+
256274 - Fee
257275 - Fie
258276 - Foe
259277
260−3. Third
278+3. Third
261279
262280Same thing but with paragraphs:
263281
264−1. First
282+
283+1. First
265284
2662852. Second:
267286
287+
268288 - Fee
269289 - Fie
270290 - Foe
271291
272−3. Third
292+3. Third
273293
274294
275295Tabs and spaces
276296---------------
277297
298+
278299- this is a list item indented with tabs
279300
280301- this is a list item indented with spaces
281302
303+
282304 - this is an example list item indented with tabs
283305
284306 - this is an example list item indented with spaces
285307
286308
287309
310+Fancy list markers
311+------------------
312+
313+
314+(2) begins with 2
315+(3) and now 3
316+
317+ with a continuation
318+
319+
320+ iv. sublist with roman numerals, starting with 4
321+ v. more items
322+
323+ (A) a subsublist
324+ (B) a subsublist
325+
326+
327+
328+Nesting:
329+
330+
331+A. Upper Alpha
332+
333+ I. Upper Roman.
334+
335+ (6) Decimal start with 6
336+
337+ c) Lower alpha with paren
338+
339+
340+
341+
342+Autonumbering:
343+
344+
345+#. Autonumber.
346+#. More.
347+
348+ #. Nested.
349+
350+
288351--------------
289352
290353Definition Lists
@@ -572,6 +635,7 @@ Ellipses...and...and....
572635LaTeX
573636=====
574637
638+
575639- \cite[22-23]{smith.1899}
576640- \doublespacing
577641- $2+2=4$
@@ -585,6 +649,7 @@ LaTeX
585649
586650These shouldn't be math:
587651
652+
588653- To get the famous equation, write ``$e = mc^2$``.
589654- $22,000 is a *lot* of money. So is $34,000. (It worked if "lot"
590655 is emphasized.)
@@ -608,6 +673,7 @@ Special Characters
608673
609674Here is some unicode:
610675
676+
611677- I hat: Î
612678- o umlaut: ö
613679- section: §
@@ -729,6 +795,7 @@ Autolinks
729795
730796With an ampersand: http://example.com/?foo=1&bar=2
731797
798+
732799- In a list?
733800- http://example.com/
734801- It should.
@@ -767,7 +834,8 @@ note] Here is an inline note. [3]_
767834 Notes can go in quotes. [4]_
768835
769836
770−1. And in list items. [5]_
837+
838+1. And in list items. [5]_
771839
772840This paragraph should not be part of the note, as it is not
773841indented.
tests/writer.rtf+17
@@ -140,6 +140,23 @@ These should not be escaped: \\$ \\\\ \\> \\[ \\\{\par}
140140{\pard \ql \f0 \sa180 \li360 \fi-360 \bullet \tx360\tab this is a list item indented with spaces\par}
141141{\pard \ql \f0 \sa180 \li720 \fi-360 \endash \tx360\tab this is an example list item indented with tabs\par}
142142{\pard \ql \f0 \sa180 \li720 \fi-360 \endash \tx360\tab this is an example list item indented with spaces\sa180\sa180\par}
143+{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs32 Fancy list markers\par}
144+{\pard \ql \f0 \sa0 \li360 \fi-360 (2)\tx360\tab begins with 2\par}
145+{\pard \ql \f0 \sa180 \li360 \fi-360 (3)\tx360\tab and now 3\par}
146+{\pard \ql \f0 \sa180 \li360 \fi0 with a continuation\par}
147+{\pard \ql \f0 \sa0 \li720 \fi-360 iv.\tx360\tab sublist with roman numerals, starting with 4\par}
148+{\pard \ql \f0 \sa0 \li720 \fi-360 v.\tx360\tab more items\par}
149+{\pard \ql \f0 \sa0 \li1080 \fi-360 (A)\tx360\tab a subsublist\par}
150+{\pard \ql \f0 \sa0 \li1080 \fi-360 (B)\tx360\tab a subsublist\sa180\sa180\sa180\par}
151+{\pard \ql \f0 \sa180 \li0 \fi0 Nesting:\par}
152+{\pard \ql \f0 \sa0 \li360 \fi-360 A.\tx360\tab Upper Alpha\par}
153+{\pard \ql \f0 \sa0 \li720 \fi-360 I.\tx360\tab Upper Roman.\par}
154+{\pard \ql \f0 \sa0 \li1080 \fi-360 (6)\tx360\tab Decimal start with 6\par}
155+{\pard \ql \f0 \sa0 \li1440 \fi-360 c)\tx360\tab Lower alpha with paren\sa180\sa180\sa180\sa180\par}
156+{\pard \ql \f0 \sa180 \li0 \fi0 Autonumbering:\par}
157+{\pard \ql \f0 \sa0 \li360 \fi-360 1.\tx360\tab Autonumber.\par}
158+{\pard \ql \f0 \sa0 \li360 \fi-360 2.\tx360\tab More.\par}
159+{\pard \ql \f0 \sa0 \li720 \fi-360 a.\tx360\tab Nested.\sa180\sa180\par}
143160{\pard \qc \f0 \sa180 \li0 \fi0 \emdash\emdash\emdash\emdash\emdash\par}
144161{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs36 Definition Lists\par}
145162{\pard \ql \f0 \sa180 \li0 \fi0 Tight using spaces:\par}