Skip to content

Commit f0f168c

Browse files
committed
feat: allow using inline components inside parentheses
resolves #77
1 parent 94d9d97 commit f0f168c

File tree

3 files changed

+117
-1
lines changed

3 files changed

+117
-1
lines changed

src/micromark-extension/tokenize-inline.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function tokenize (this: TokenizeContext, effects: Effects, ok: State, nok: Stat
2626
if (
2727
self.previous !== null &&
2828
!markdownLineEndingOrSpace(self.previous) &&
29-
![Codes.openingSquareBracket, Codes.star, Codes.underscore].includes(self.previous)
29+
![Codes.openingSquareBracket, Codes.star, Codes.underscore, Codes.openingParentheses].includes(self.previous)
3030
) {
3131
return nok(code)
3232
}

test/__snapshots__/inline-component.test.ts.snap

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,119 @@ exports[`inline-component > empty 1`] = `
206206
}
207207
`;
208208

209+
exports[`inline-component > parentheses 1`] = `
210+
{
211+
"children": [
212+
{
213+
"children": [
214+
{
215+
"position": {
216+
"end": {
217+
"column": 2,
218+
"line": 1,
219+
"offset": 1,
220+
},
221+
"start": {
222+
"column": 1,
223+
"line": 1,
224+
"offset": 0,
225+
},
226+
},
227+
"type": "text",
228+
"value": "(",
229+
},
230+
{
231+
"attributes": {
232+
"class": "class",
233+
},
234+
"children": [
235+
{
236+
"position": {
237+
"end": {
238+
"column": 17,
239+
"line": 1,
240+
"offset": 16,
241+
},
242+
"start": {
243+
"column": 13,
244+
"line": 1,
245+
"offset": 12,
246+
},
247+
},
248+
"type": "text",
249+
"value": "text",
250+
},
251+
],
252+
"data": {
253+
"hName": "component",
254+
"hProperties": {
255+
"class": "class",
256+
},
257+
},
258+
"fmAttributes": {},
259+
"name": "component",
260+
"position": {
261+
"end": {
262+
"column": 26,
263+
"line": 1,
264+
"offset": 25,
265+
},
266+
"start": {
267+
"column": 2,
268+
"line": 1,
269+
"offset": 1,
270+
},
271+
},
272+
"type": "textComponent",
273+
},
274+
{
275+
"position": {
276+
"end": {
277+
"column": 27,
278+
"line": 1,
279+
"offset": 26,
280+
},
281+
"start": {
282+
"column": 26,
283+
"line": 1,
284+
"offset": 25,
285+
},
286+
},
287+
"type": "text",
288+
"value": ")",
289+
},
290+
],
291+
"position": {
292+
"end": {
293+
"column": 27,
294+
"line": 1,
295+
"offset": 26,
296+
},
297+
"start": {
298+
"column": 1,
299+
"line": 1,
300+
"offset": 0,
301+
},
302+
},
303+
"type": "paragraph",
304+
},
305+
],
306+
"position": {
307+
"end": {
308+
"column": 27,
309+
"line": 1,
310+
"offset": 26,
311+
},
312+
"start": {
313+
"column": 1,
314+
"line": 1,
315+
"offset": 0,
316+
},
317+
},
318+
"type": "root",
319+
}
320+
`;
321+
209322
exports[`inline-component > strong 1`] = `
210323
{
211324
"children": [

test/inline-component.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ describe('inline-component', () => {
2222
underlined: {
2323
markdown: '**:component[text]{.class}**'
2424
},
25+
parentheses: {
26+
markdown: '(:component[text]{.class})'
27+
},
2528
binding: {
2629
markdown: '{{ $doc.variable }}'
2730
},

0 commit comments

Comments
 (0)