Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(parser/renderer): support listing blocks #42

Merged
merged 1 commit into from
Nov 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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