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): support relative links #65

Merged
merged 1 commit into from
Feb 18, 2018
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
15 changes: 12 additions & 3 deletions parser/asciidoc-grammar.peg
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ InlineContent <- !BlockDelimiter elements:(WS* InlineElement WS*)+ &EOL { // nee
return types.NewInlineContent(elements.([]interface{}))
}

InlineElement <- CrossReference / Passthrough / InlineImage / QuotedText / ExternalLink / DocumentAttributeSubstitution / Characters
InlineElement <- CrossReference / Passthrough / InlineImage / QuotedText / Link / DocumentAttributeSubstitution / Characters

// ----------------------------------------------------------------------------
// Quoted Texts (bold, italic and monospace) including substitution prevention
Expand Down Expand Up @@ -443,11 +443,20 @@ CrossReference <- "<<" id:(ID) ">>" {
// ------------------------------------------
// Links
// ------------------------------------------
Link <- RelativeLink / ExternalLink

ExternalLink <- url:(URL_SCHEME URL) text:("[" (URL_TEXT)* "]")? {
if text != nil {
return types.NewExternalLink(url.([]interface{}), text.([]interface{}))
return types.NewLink(url.([]interface{}), text.([]interface{}))
}
return types.NewLink(url.([]interface{}), nil)
}

RelativeLink <- "link:" url:(URL_SCHEME? URL) text:("[" (URL_TEXT)* "]") {
if text != nil {
return types.NewLink(url.([]interface{}), text.([]interface{}))
}
return types.NewExternalLink(url.([]interface{}), nil)
return types.NewLink(url.([]interface{}), nil)
}

// ------------------------------------------
Expand Down
Loading