Skip to content

Commit 4eedd96

Browse files
committed
Add punctuation support in LiquidDoc param descriptions
1 parent d4cb262 commit 4eedd96

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

packages/liquid-html-parser/grammar/liquid-html.ohm

+2-1
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,8 @@ LiquidDoc <: Helpers {
398398
paramNode = "@param" space* (paramType)? space* (paramName)? space* "-"? paramDescription?
399399
paramType = "{" anyExceptStar<"}"> "}"
400400
paramName = (~"-" identifierCharacter)+
401-
paramDescription = (~newline identifierCharacter | space)+
401+
paramDescription = (~newline identifierCharacter | space | punctuation)+
402+
punctuation = singleQuote | doubleQuote | "." | "`"
402403
}
403404

404405
LiquidHTML <: Liquid {

packages/liquid-html-parser/src/stage-1-cst.spec.ts

+9
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,15 @@ describe('Unit: Stage 1 (CST)', () => {
10711071
expectPath(cst, '0.children.2.paramDescription.dashSeparated').to.equal(false);
10721072
});
10731073

1074+
it('should accept punctation inside the param description body', () => {
1075+
const testStr = `{% doc %} @param paramName paramDescription - asdf . \`should\` work {% enddoc %}`;
1076+
cst = toCST(testStr);
1077+
1078+
expectPath(cst, '0.children.0.paramDescription.value').to.equal(
1079+
'paramDescription - asdf . `should` work',
1080+
);
1081+
});
1082+
10741083
it('should parse unsupported doc tags as text nodes', () => {
10751084
const testStr = `{% doc %} @unsupported this tag is not supported {% enddoc %}`;
10761085
cst = toCST(testStr);

packages/liquid-html-parser/src/stage-2-ast.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,7 @@ describe('Unit: Stage 2 (AST)', () => {
12321232
ast = toLiquidAST(`
12331233
{% doc -%}
12341234
@param asdf
1235-
@param {String} paramWithDescription - param with description
1235+
@param {String} paramWithDescription - param with description and \`punctation\`. This is still a valid param description.
12361236
@unsupported this node falls back to a text node
12371237
{%- enddoc %}
12381238
`);
@@ -1252,7 +1252,7 @@ describe('Unit: Stage 2 (AST)', () => {
12521252
expectPath(ast, 'children.0.body.nodes.1.paramDescription.type').to.eql('TextNode');
12531253
expectPath(ast, 'children.0.body.nodes.1.paramDescription.dashSeparated').to.eql(true);
12541254
expectPath(ast, 'children.0.body.nodes.1.paramDescription.value').to.eql(
1255-
'param with description',
1255+
'param with description and `punctation`. This is still a valid param description.',
12561256
);
12571257
expectPath(ast, 'children.0.body.nodes.1.paramType.type').to.eql('TextNode');
12581258
expectPath(ast, 'children.0.body.nodes.1.paramType.value').to.eql('String');

0 commit comments

Comments
 (0)