Skip to content

Commit

Permalink
feat(parser/renderer): support listing blocks (#42)
Browse files Browse the repository at this point in the history
using the `----` delimiter

Signed-off-by: Xavier Coulon <[email protected]>
  • Loading branch information
xcoulon authored Nov 14, 2017
1 parent aa501da commit 2fb5fe6
Show file tree
Hide file tree
Showing 7 changed files with 901 additions and 655 deletions.
10 changes: 5 additions & 5 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ It is is available under the terms of the https://raw.githubusercontent.com/byte
* Title and Sections (level 1 to 6)
* Document attribute declaration (after the title and within the rest of the document) and substitution
* Paragraphs
* Delimited Source Blocks (using the `+++```+++` delimiter, a.k.a "fences")
* Literal blocks (paragraph starting with a space, with the "...." delimiter or with the `[literal]` attribute)
* Quoted text (+bold+, _italic_ and `monospace`) and substitution prevention using the `\` escape character
* Passtrough (wrapping with a single plus or a triple plus, or using the `pass:[]` or `pass:q[]` macros)
* Delimited Source Blocks (using the `+++```+++` ("fences") delimiter for source code or the `----` delimiter for listing)
* Literal blocks (paragraph starting with a space, with the `+++....+++` delimiter or with the `[literal]` attribute)
* Quoted text (+bold+, _italic_ and `monospace`) and substitution prevention using the backslash (`\`) character
* Passtrough (wrapping with a single plus or a triple plus, or using the `+++pass:[]+++` or `+++pass:q[]+++` macros)
* Unordered lists, using the `-` marker for simple lists, or the `\*` marker for nested lists (and `\**`, `\***`, etc. for the sublists)
* External links in paragraphs (`https://`, `http://`, `ftp://`, `irc://`, `mailto:`)
* Inline images in paragraphs (`image://`)
* Block images (`image:://`)
* Element attributes (ID, link and title, when applicable) on block images, paragraphs, lists and sections
* Element attributes (`ID`, `link` and `title`, where applicable) on block images, paragraphs, lists and sections


See the http://LIMITATIONS.adoc[known limitations] page for differences between Asciidoc/Asciidoctor and Libasciidoc.
Expand Down
18 changes: 14 additions & 4 deletions parser/asciidoc-grammar.peg
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ Paragraph <- attributes:(ElementAttribute)* !("="+ WS+) lines:(InlineContent EOL

// an inline content element may start with and end with spaces,
// but it must contain at least an inline element (image, quoted text, external link, document attribute substitution, word, etc.)
InlineContent <- !FencedBlockDelimiter elements:(WS* InlineElement WS*)+ &EOL { // needs an "EOL" but does not consume it here.
InlineContent <- !BlockDelimiter elements:(WS* InlineElement WS*)+ &EOL { // needs an "EOL" but does not consume it here.
return types.NewInlineContent(elements.([]interface{}))
}

Expand Down Expand Up @@ -390,16 +390,26 @@ InlineImageMacro <- "image:" !":" path:(URL) "[" attributes:(URL_TEXT?) "]" {
// ------------------------------------------------------------------------------------
// Delimited Blocks (http://asciidoctor.org/docs/user-manual/#built-in-blocks-summary)
// ------------------------------------------------------------------------------------
DelimitedBlock <- FencedBlock
DelimitedBlock <- FencedBlock / ListingBlock

BlockDelimiter <- FencedBlockDelimiter / ListingBlockDelimiter

FencedBlockDelimiter <- "```"

FencedBlock <- FencedBlockDelimiter WS* NEWLINE content:(FencedBlockContent) FencedBlockDelimiter WS* EOL {
return types.NewDelimitedBlock(types.FencedBlock, content.([]interface{}))
}

FencedBlockDelimiter <- "```"

FencedBlockContent <- content:(!FencedBlockDelimiter .)*

ListingBlockDelimiter <- "----"

ListingBlock <- ListingBlockDelimiter WS* NEWLINE content:(ListingBlockContent) ListingBlockDelimiter WS* EOL {
return types.NewDelimitedBlock(types.ListingBlock, content.([]interface{}))
}

ListingBlockContent <- content:(!ListingBlockDelimiter .)*

// -------------------------------------------------------------------------------------
// Literal Blocks (see http://asciidoctor.org/docs/user-manual/#literal-text-and-blocks)
// -------------------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 2fb5fe6

Please sign in to comment.