diff --git a/grammar.js b/grammar.js index 9863085..47af69f 100644 --- a/grammar.js +++ b/grammar.js @@ -238,11 +238,23 @@ module.exports = grammar({ $.embedded_engine_name, optional($.attrs), ':', - $._text_nested + optional($._space), + optional($._element_rest_text), + optional($._text_nested) ), embedded_engine_name: $ => choice( - 'markdown', 'textile', 'rdoc', 'coffee', 'less', 'sass', 'scss', 'javascript', 'css', 'ruby' + // These keywords are not supported as tag names for now + token(prec(1, 'markdown')), + token(prec(1, 'textile')), + token(prec(1, 'rdoc')), + token(prec(1, 'coffee')), + token(prec(1, 'less')), + token(prec(1, 'sass')), + token(prec(1, 'scss')), + token(prec(1, 'javascript')), + token(prec(1, 'css')), + token(prec(1, 'ruby')) ), verbatim_text: $ => seq( diff --git a/src/grammar.json b/src/grammar.json index 59429c5..c02fcce 100644 --- a/src/grammar.json +++ b/src/grammar.json @@ -1315,8 +1315,40 @@ "value": ":" }, { - "type": "SYMBOL", - "name": "_text_nested" + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "_space" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "_element_rest_text" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "_text_nested" + }, + { + "type": "BLANK" + } + ] } ] }, @@ -1324,44 +1356,114 @@ "type": "CHOICE", "members": [ { - "type": "STRING", - "value": "markdown" + "type": "TOKEN", + "content": { + "type": "PREC", + "value": 1, + "content": { + "type": "STRING", + "value": "markdown" + } + } }, { - "type": "STRING", - "value": "textile" + "type": "TOKEN", + "content": { + "type": "PREC", + "value": 1, + "content": { + "type": "STRING", + "value": "textile" + } + } }, { - "type": "STRING", - "value": "rdoc" + "type": "TOKEN", + "content": { + "type": "PREC", + "value": 1, + "content": { + "type": "STRING", + "value": "rdoc" + } + } }, { - "type": "STRING", - "value": "coffee" + "type": "TOKEN", + "content": { + "type": "PREC", + "value": 1, + "content": { + "type": "STRING", + "value": "coffee" + } + } }, { - "type": "STRING", - "value": "less" + "type": "TOKEN", + "content": { + "type": "PREC", + "value": 1, + "content": { + "type": "STRING", + "value": "less" + } + } }, { - "type": "STRING", - "value": "sass" + "type": "TOKEN", + "content": { + "type": "PREC", + "value": 1, + "content": { + "type": "STRING", + "value": "sass" + } + } }, { - "type": "STRING", - "value": "scss" + "type": "TOKEN", + "content": { + "type": "PREC", + "value": 1, + "content": { + "type": "STRING", + "value": "scss" + } + } }, { - "type": "STRING", - "value": "javascript" + "type": "TOKEN", + "content": { + "type": "PREC", + "value": 1, + "content": { + "type": "STRING", + "value": "javascript" + } + } }, { - "type": "STRING", - "value": "css" + "type": "TOKEN", + "content": { + "type": "PREC", + "value": 1, + "content": { + "type": "STRING", + "value": "css" + } + } }, { - "type": "STRING", - "value": "ruby" + "type": "TOKEN", + "content": { + "type": "PREC", + "value": 1, + "content": { + "type": "STRING", + "value": "ruby" + } + } } ] }, diff --git a/test/corpus/embedded_engine.txt b/test/corpus/embedded_engine.txt index f431b2c..5713190 100644 --- a/test/corpus/embedded_engine.txt +++ b/test/corpus/embedded_engine.txt @@ -12,3 +12,39 @@ javascript: (source_file (embedded_engine (embedded_engine_name))) + +=================================== +Embedded engine with inline content +=================================== + +javascript: alert(); + +--- + +(source_file + (embedded_engine + (embedded_engine_name))) + +============================================= +Embedded engine with inline content, no space +============================================= + +javascript:alert(); + +--- + +(source_file + (embedded_engine + (embedded_engine_name))) + +===================== +Empty embedded engine +===================== + +javascript: + +--- + +(source_file + (embedded_engine + (embedded_engine_name)))