Skip to content

Commit

Permalink
Merge cc01e82 into 0b04317
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkkrp committed Dec 3, 2017
2 parents 0b04317 + cc01e82 commit d1a73bc
Show file tree
Hide file tree
Showing 4 changed files with 720 additions and 140 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,23 @@ do, the closing `*` won't be in right-flanking position anymore. God dammit.

Block-level parsing:

* Headings, thematic breaks, code blocks should be separated from paragraphs
by at least one empty line. This makes the parser a lot simpler and forces
markdown sources to be in a more readable form too.
* Code blocks and thematic breaks should be separated from paragraphs and
lists by at least one empty line.
* If a line starts with hash signs it is expected to be a valid *non-empty*
header (level 1–6 inclusive). If you want to start a paragraph with
hashes, just escape the first hash with backslash and that will be enough.
* Setext headings are not supported for the sake of simplicity.
* Fenced code blocks must be explicitly closed by a closing fence. They are
not closed by the end of document or by start of another block.
* Lists and block quotes are defined by column at which their content
starts. Content belonging to a particular list or block quote should start
at the same column (or greater column, up to the column where indented
code blocks start).
* Block quotes are started by a single `>` character, it's not necessary to
put a `>` character at beginning of every line belonging to a quote (in
fact, this would make every line a separate block quote).
* Paragraphs can be interrupted by unordered list and ordered lists with any
valid starting index.

Inline-level parsing:

Expand Down
20 changes: 11 additions & 9 deletions Text/MMark/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ data Block a
-- ^ Paragraph, leaf block
| Blockquote [Block a]
-- ^ Blockquote container block
| OrderedList (NonEmpty [Block a])
-- ^ Ordered list, container block
| OrderedList Word (NonEmpty [Block a])
-- ^ Ordered list ('Word' is the start index), container block
| UnorderedList (NonEmpty [Block a])
-- ^ Unordered list, container block
| Naked a
Expand Down Expand Up @@ -336,24 +336,26 @@ defaultBlockRender = \case
newline
Paragraph (_,html) ->
p_ html >> newline
Blockquote blocks ->
blockquote_ (mapM_ defaultBlockRender blocks)
OrderedList items -> do
ol_ $ do
Blockquote blocks -> do
blockquote_ (newline <* mapM_ defaultBlockRender blocks)
newline
OrderedList i items -> do
let startIndex = [start_ (T.pack $ show i) | i /= 1]
ol_ startIndex $ do
newline
forM_ items $ \x -> do
li_ (mapM_ defaultBlockRender x)
li_ (newline <* mapM_ defaultBlockRender x)
newline
newline
UnorderedList items -> do
ul_ $ do
newline
forM_ items $ \x -> do
li_ (mapM_ defaultBlockRender x)
li_ (newline <* mapM_ defaultBlockRender x)
newline
newline
Naked (_,html) ->
html
html >> newline
where
mkId (Ois x) = [id_ (headerId x)]

Expand Down

0 comments on commit d1a73bc

Please sign in to comment.