Skip to content

Commit

Permalink
Merge branch 'next'
Browse files Browse the repository at this point in the history
  • Loading branch information
kellyjosephprice committed Apr 5, 2024
2 parents 09fcbb3 + 3b48c90 commit 50f43f1
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@ Object {
],
"position": Position {
"end": Object {
"column": 1,
"column": 2,
"line": 3,
"offset": 23,
"offset": 24,
},
"indent": Array [
1,
Expand Down
17 changes: 17 additions & 0 deletions __tests__/flavored-parsers/reusable-content.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
import { mdast } from '../../index';

describe('reusable content transfomer', () => {
it('parses camel cased content', () => {
const md = '<TestComponent />';
const tree = mdast(md);

expect(tree.children[0].type).toBe('reusable-content');
expect(tree.children[0].tag).toBe('TestComponent');
});

it('parses content in a container', () => {
const md = '> <TestComponent />';
const tree = mdast(md);

expect(tree.children[0].type).toBe('blockquote');
expect(tree.children[0].children[0].type).toBe('reusable-content');
expect(tree.children[0].children[0].tag).toBe('TestComponent');
});

it('should replace a reusable content block if the block is provided', () => {
const tags = {
Test: `
Expand Down
1 change: 1 addition & 0 deletions components/Image/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

&[width='80%'],
&[align='center'],
&[align='middle'],
&[alt~='align-center'] {
@extend %img-align-center;
}
Expand Down
2 changes: 1 addition & 1 deletion processor/parse/reusable-content-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function tokenizeReusableContent(eat, value, silent) {

// Modifies the regular expression to match from
// the start of the line
const match = /^<(?<tag>[A-Z]\S+)\s*\/>\s*\n/.exec(value);
const match = /^<(?<tag>[A-Z]\S+)\s*\/>\s*/.exec(value);

if (!match || !match.groups.tag) return false;
const { tag } = match.groups;
Expand Down

0 comments on commit 50f43f1

Please sign in to comment.