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 inline footnotes #183

Merged
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
26 changes: 23 additions & 3 deletions pkg/parser/asciidoc-grammar.peg
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ TitleElements <- elements:(!NEWLINE WS* !InlineElementID TitleElement WS*)+ { //
return types.NewInlineElements(elements.([]interface{}))
}

TitleElement <- element:(CrossReference / Passthrough / InlineImage / QuotedText / Link / DocumentAttributeSubstitution / Word / Parenthesis) {
TitleElement <- element:(CrossReference / Passthrough / InlineImage / QuotedText / Link / DocumentAttributeSubstitution / InlineFootnote / Word / Parenthesis) {
return element, nil
}

Expand Down Expand Up @@ -527,7 +527,7 @@ InlineElements <-
return types.NewInlineElements(elements.([]interface{}))
}

InlineElement <- element:(QuotedText / CrossReference / Passthrough / InlineImage / Link / DocumentAttributeSubstitution / Word / Parenthesis) {
InlineElement <- element:(QuotedText / CrossReference / Passthrough / InlineImage / Link / DocumentAttributeSubstitution / InlineFootnote / Word / Parenthesis) {
return element, nil
}

Expand Down Expand Up @@ -734,7 +734,27 @@ ImageAttribute <- (!"," !"=" !"]" .)+ { // attribute is followed by "," or "]" (
}

// ------------------------------------------------------------------------------------
// Delimited Blocks (http://asciidoctor.org/docs/user-manual/#built-in-blocks-summary)
// Inline foot notes
// ------------------------------------------------------------------------------------
InlineFootnote <- "footnote:[" content:(FootnoteContent) "]" {
return types.NewFootnote("", content.(types.InlineElements))
} / "footnoteref:[" ref:(FootnoteRef) "," content:(FootnoteContent) "]" {
return types.NewFootnote(ref.(string), content.(types.InlineElements))
} / "footnoteref:[" ref:(FootnoteRef) "]" {
return types.NewFootnote(ref.(string), types.InlineElements{}) // foot note referring to another note
}

FootnoteRef <- (!"," !"]" !EOL .)* { // footnote ID not may span multiple lines
return string(c.text), nil
}

FootnoteContent <- elements:(!"]" !EOL WS* !InlineElementID InlineElement WS*)+ { // footnote content may span multiple lines
return types.NewInlineElements(elements.([]interface{}))
}


// ------------------------------------------------------------------------------------
// Delimited Blocks
// ------------------------------------------------------------------------------------
DelimitedBlock <- FencedBlock / ListingBlock / ExampleBlock
/ CommentBlock / VerseBlock / QuoteBlock
Expand Down
Loading