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

(ebnf) add backtick (grave symbol) as string character #2290

Merged
merged 4 commits into from
Nov 29, 2019
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
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ New styles:
none.

Improvements:
- enh(ebnf) add backticks as additional string variant (#2290) [Chris Marchesi][]
- fix(themes): fix inconsistencies between some themes padding/spacing (#2300) [Josh Goebel][]
- chore(javascript): add esm related extensions to aliases (#2298) [Rongjian Zhang][]
- fix(kotlin): fix termination of """ string literals (#2295) [Josh Goebel][]
Expand Down
11 changes: 9 additions & 2 deletions src/languages/ebnf.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,15 @@ function(hljs) {
contains: [
commentMode,
specialSequenceMode,
// terminals
hljs.APOS_STRING_MODE, hljs.QUOTE_STRING_MODE
{
// terminals
className: 'string',
variants: [
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE,
{begin: '`', end: '`'},
]
},
]
};

Expand Down
8 changes: 8 additions & 0 deletions test/markup/ebnf/quote-symbols.expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<span class="hljs-attribute">first_quote_symbol</span> = <span class="hljs-string">"'"</span> .
<span class="hljs-attribute">second_quote_symbol</span> = <span class="hljs-string">'"'</span> .

<span class="hljs-comment">(* escaped_quote_symbol tests backticks, which does not interfere
* with backslashes. It has precedent in some language
* specifications.
*)</span>
<span class="hljs-attribute">escaped_quote_symbol</span> = <span class="hljs-string">`\`</span> ( first_quote_symbol | second_quote_symbol ) .
8 changes: 8 additions & 0 deletions test/markup/ebnf/quote-symbols.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
first_quote_symbol = "'" .
second_quote_symbol = '"' .

(* escaped_quote_symbol tests backticks, which does not interfere
* with backslashes. It has precedent in some language
* specifications.
*)
escaped_quote_symbol = `\` ( first_quote_symbol | second_quote_symbol ) .