Skip to content

Commit

Permalink
feat: allow using inline components inside parentheses
Browse files Browse the repository at this point in the history
resolves #77
  • Loading branch information
farnabaz committed Nov 18, 2024
1 parent 94d9d97 commit f0f168c
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/micromark-extension/tokenize-inline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function tokenize (this: TokenizeContext, effects: Effects, ok: State, nok: Stat
if (
self.previous !== null &&
!markdownLineEndingOrSpace(self.previous) &&
![Codes.openingSquareBracket, Codes.star, Codes.underscore].includes(self.previous)
![Codes.openingSquareBracket, Codes.star, Codes.underscore, Codes.openingParentheses].includes(self.previous)
) {
return nok(code)
}
Expand Down
113 changes: 113 additions & 0 deletions test/__snapshots__/inline-component.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,119 @@ exports[`inline-component > empty 1`] = `
}
`;

exports[`inline-component > parentheses 1`] = `
{
"children": [
{
"children": [
{
"position": {
"end": {
"column": 2,
"line": 1,
"offset": 1,
},
"start": {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "text",
"value": "(",
},
{
"attributes": {
"class": "class",
},
"children": [
{
"position": {
"end": {
"column": 17,
"line": 1,
"offset": 16,
},
"start": {
"column": 13,
"line": 1,
"offset": 12,
},
},
"type": "text",
"value": "text",
},
],
"data": {
"hName": "component",
"hProperties": {
"class": "class",
},
},
"fmAttributes": {},
"name": "component",
"position": {
"end": {
"column": 26,
"line": 1,
"offset": 25,
},
"start": {
"column": 2,
"line": 1,
"offset": 1,
},
},
"type": "textComponent",
},
{
"position": {
"end": {
"column": 27,
"line": 1,
"offset": 26,
},
"start": {
"column": 26,
"line": 1,
"offset": 25,
},
},
"type": "text",
"value": ")",
},
],
"position": {
"end": {
"column": 27,
"line": 1,
"offset": 26,
},
"start": {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "paragraph",
},
],
"position": {
"end": {
"column": 27,
"line": 1,
"offset": 26,
},
"start": {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "root",
}
`;

exports[`inline-component > strong 1`] = `
{
"children": [
Expand Down
3 changes: 3 additions & 0 deletions test/inline-component.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ describe('inline-component', () => {
underlined: {
markdown: '**:component[text]{.class}**'
},
parentheses: {
markdown: '(:component[text]{.class})'
},
binding: {
markdown: '{{ $doc.variable }}'
},
Expand Down

0 comments on commit f0f168c

Please sign in to comment.