|
|
@@ -113,7 +113,7 @@ test('micromark-extension-directive (syntax)', (t) => {
|
|
|
t.equal(
|
|
|
micromark('$a(', options()),
|
|
|
'<p>(</p>',
|
|
|
- 'should support a name followed by an unclosed `{`',
|
|
|
+ 'should support a name followed by an unclosed `(`',
|
|
|
);
|
|
|
|
|
|
t.equal(
|
|
|
@@ -125,7 +125,7 @@ test('micromark-extension-directive (syntax)', (t) => {
|
|
|
t.equal(
|
|
|
micromark('$a(b', options()),
|
|
|
'<p>(b</p>',
|
|
|
- 'should support a name followed by an unclosed `{` w/ content',
|
|
|
+ 'should support a name followed by an unclosed `(` w/ content',
|
|
|
);
|
|
|
|
|
|
t.equal(
|
|
|
@@ -326,6 +326,12 @@ test('micromark-extension-directive (syntax)', (t) => {
|
|
|
'should not support a grave accent in an unquoted attribute value',
|
|
|
);
|
|
|
|
|
|
+ t.equal(
|
|
|
+ micromark('a $a(b💚=a💚b)', options()),
|
|
|
+ '<p>a </p>',
|
|
|
+ 'should support most other characters in attribute keys',
|
|
|
+ );
|
|
|
+
|
|
|
t.equal(
|
|
|
micromark('a $a(b=a💚b)', options()),
|
|
|
'<p>a </p>',
|
|
|
@@ -547,6 +553,12 @@ test('micromark-extension-directive (syntax)', (t) => {
|
|
|
// 'should not support `=` to start an unquoted attribute value',
|
|
|
// );
|
|
|
|
|
|
+ t.equal(
|
|
|
+ micromark('$a(b💚=a💚b)', options()),
|
|
|
+ '',
|
|
|
+ 'should support most other characters in attribute keys',
|
|
|
+ );
|
|
|
+
|
|
|
t.equal(
|
|
|
micromark('$a(b=a💚b)', options()),
|
|
|
'',
|
|
|
@@ -772,6 +784,41 @@ test('micromark-extension-directive (compile)', (t) => {
|
|
|
'should support directives (youtube)',
|
|
|
);
|
|
|
|
|
|
+ t.equal(
|
|
|
+ micromark(
|
|
|
+ [
|
|
|
+ 'Text:',
|
|
|
+ 'a $lsx',
|
|
|
+ 'a $lsx()',
|
|
|
+ 'a $lsx(num=1)',
|
|
|
+ 'a $lsx(/)',
|
|
|
+ 'a $lsx(💚)',
|
|
|
+ 'Leaf:',
|
|
|
+ '$lsx',
|
|
|
+ '$lsx()',
|
|
|
+ '$lsx(num=1)',
|
|
|
+ '$lsx(/)',
|
|
|
+ '$lsx(💚)',
|
|
|
+ ].join('\n\n'),
|
|
|
+ options({ lsx }),
|
|
|
+ ),
|
|
|
+ [
|
|
|
+ '<p>Text:</p>',
|
|
|
+ '<p>a <lsx ></lsx></p>',
|
|
|
+ '<p>a <lsx ></lsx></p>',
|
|
|
+ '<p>a <lsx num="1"></lsx></p>',
|
|
|
+ '<p>a <lsx prefix="/"></lsx></p>',
|
|
|
+ '<p>a <lsx prefix="💚"></lsx></p>',
|
|
|
+ '<p>Leaf:</p>',
|
|
|
+ '<lsx ></lsx>',
|
|
|
+ '<lsx ></lsx>',
|
|
|
+ '<lsx num="1"></lsx>',
|
|
|
+ '<lsx prefix="/"></lsx>',
|
|
|
+ '<lsx prefix="💚"></lsx>',
|
|
|
+ ].join('\n'),
|
|
|
+ 'should support directives (lsx)',
|
|
|
+ );
|
|
|
+
|
|
|
t.equal(
|
|
|
micromark('a $youtube[Cat in a box]\n$br a', options({ youtube, '*': h })),
|
|
|
'<p>a <youtube>Cat in a box</youtube>\n<br> a</p>',
|
|
|
@@ -1051,6 +1098,26 @@ function youtube(d) {
|
|
|
this.tag('</iframe>');
|
|
|
}
|
|
|
|
|
|
+/** @type {Handle} */
|
|
|
+function lsx(d) {
|
|
|
+ const attrs = d.attributes || {};
|
|
|
+
|
|
|
+ const props = [];
|
|
|
+
|
|
|
+ // eslint-disable-next-line no-restricted-syntax
|
|
|
+ for (const key in attrs) {
|
|
|
+ if (attrs[key].length === 0) {
|
|
|
+ props.push(`prefix="${key}"`);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ props.push(`${key}="${attrs[key]}"`);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ this.tag(`<lsx ${props.join(' ')}>`);
|
|
|
+ this.tag('</lsx>');
|
|
|
+}
|
|
|
+
|
|
|
/** @type {Handle} */
|
|
|
function h(d) {
|
|
|
const content = d.content || d.label;
|