From e814a3f6d23f640b1aed5b7cb949459d514a3e33 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Wed, 8 Aug 2007 02:43:15 +0000 Subject: 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 --- src/Text/Pandoc/Readers/Markdown.hs | 41 ++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 16 deletions(-) (limited to 'src/Text/Pandoc/Readers/Markdown.hs') diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 0ecb09178..3ccb74ba7 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -243,6 +243,8 @@ header = choice [ setextHeader, atxHeader ] "header" atxHeader = try (do lead <- many1 (char '#') + notFollowedBy (char '.') -- this would be a list + notFollowedBy (char ')') skipSpaces txt <- manyTill inline atxClosing return (Header (length lead) (normalizeSpaces txt))) @@ -354,27 +356,33 @@ blockQuote = do list = choice [ bulletList, orderedList, definitionList ] "list" -bulletListStart = try (do +bulletListStart = try $ do option ' ' newline -- if preceded by a Plain block in a list context nonindentSpaces notFollowedBy' hrule -- because hrules start out just like lists oneOf bulletListMarkers spaceChar - skipSpaces) - -standardOrderedListStart = try (do - many1 digit - char '.') + skipSpaces -extendedOrderedListStart = try (do - failIfStrict - oneOf ['a'..'n'] - oneOf ".)") +anyOrderedListStart = try $ do + option ' ' newline -- if preceded by a Plain block in a list context + nonindentSpaces + state <- getState + if stateStrict state + then do many1 digit + char '.' + return (1, DefaultStyle, DefaultDelim) + else anyOrderedListMarker -orderedListStart = try $ do +orderedListStart style delim = try $ do option ' ' newline -- if preceded by a Plain block in a list context nonindentSpaces - standardOrderedListStart <|> extendedOrderedListStart + state <- getState + if stateStrict state + then do many1 digit + char '.' + return 1 + else orderedListMarker style delim oneOf spaceChars skipSpaces @@ -385,7 +393,7 @@ listLine start = try (do notFollowedBy' (do indentSpaces many (spaceChar) - choice [bulletListStart, orderedListStart]) + choice [bulletListStart, anyOrderedListStart >> return ()]) line <- manyTill anyChar newline return (line ++ "\n")) @@ -431,9 +439,10 @@ listItem start = try (do return contents) orderedList = try (do - items <- many1 (listItem orderedListStart) + (start, style, delim) <- lookAhead anyOrderedListStart + items <- many1 (listItem (orderedListStart style delim)) let items' = compactify items - return (OrderedList items')) + return (OrderedList (start, style, delim) items')) bulletList = try (do items <- many1 (listItem bulletListStart) @@ -906,7 +915,7 @@ endline = try (do else return () -- parse potential list-starts differently if in a list: if (stateParserContext st) == ListItemState - then notFollowedBy' (orderedListStart <|> bulletListStart) + then notFollowedBy' $ choice [bulletListStart, anyOrderedListStart >> return ()] else return () return Space) -- cgit v1.2.3