Skip to content

Commit

Permalink
build: update remark-parse to v8 (#772)
Browse files Browse the repository at this point in the history
Updates remark-parse to v8!

We realized that we incorrect about which version of remark-parse is the complete rewrite, it's v9 not v8. And, mdx@v1 uses remark-parse@v8! So we don't have to do our rewrite yet.

This updates and fixes some _weird_ issues.
  • Loading branch information
kellyjosephprice committed Jul 5, 2023
1 parent e12967c commit 91880c9
Show file tree
Hide file tree
Showing 10 changed files with 202 additions and 255 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x, 16.x]
node-version: [16.x, 18.x]
steps:
- uses: actions/checkout@v3

Expand Down
1 change: 0 additions & 1 deletion __tests__/components/HTMLBlock.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const HTMLBlock = createHTMLBlock(createSchema(), {});

describe('HTML Block', () => {
beforeEach(() => {
global.window = true;
global.mockFn = jest.fn();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,6 @@ Object {
Object {
"children": Array [
Object {
"position": Position {
"end": Object {
"column": 33,
"line": 1,
"offset": 32,
},
"indent": Array [],
"start": Object {
"column": 18,
"line": 1,
"offset": 17,
},
},
"type": "text",
"value": "Compact Heading",
},
Expand All @@ -30,36 +17,9 @@ Object {
"id": "compact-heading",
},
"depth": 1,
"position": Position {
"end": Object {
"column": 1,
"line": 2,
"offset": 17,
},
"indent": Array [
1,
],
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "heading",
},
],
"position": Object {
"end": Object {
"column": 2,
"line": 3,
"offset": 19,
},
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "root",
}
`;
Expand All @@ -70,19 +30,6 @@ Object {
Object {
"children": Array [
Object {
"position": Position {
"end": Object {
"column": 22,
"line": 1,
"offset": 21,
},
"indent": Array [],
"start": Object {
"column": 3,
"line": 1,
"offset": 2,
},
},
"type": "text",
"value": "Non-compact Heading",
},
Expand All @@ -94,34 +41,9 @@ Object {
"id": "non-compact-heading",
},
"depth": 1,
"position": Position {
"end": Object {
"column": 22,
"line": 1,
"offset": 21,
},
"indent": Array [],
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "heading",
},
],
"position": Object {
"end": Object {
"column": 2,
"line": 3,
"offset": 24,
},
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "root",
}
`;
20 changes: 18 additions & 2 deletions __tests__/flavored-parsers/compact-headings.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,27 @@ import { mdast } from '../../index';
describe('Compact headings', () => {
it('can parse compact headings', () => {
const heading = '#Compact Heading';
expect(mdast(heading, { settings: { position: true } })).toMatchSnapshot();
expect(mdast(heading)).toMatchSnapshot();
});

it('reports the offsets for compact headings correctly', () => {
const heading = '#Compact Heading';
const tree = mdast(heading, { settings: { position: true } });

expect(tree.children[0].position.start.offset).toBe(0);
expect(tree.children[0].position.end.offset).toBe(17);
});

it('can parse headings that are not compact', () => {
const heading = '# Non-compact Heading';
expect(mdast(heading, { settings: { position: true } })).toMatchSnapshot();
expect(mdast(heading)).toMatchSnapshot();
});

it('reports the offsets for non-compact headings correctly', () => {
const heading = '# Non-compact Heading';
const tree = mdast(heading, { settings: { position: true } });

expect(tree.children[0].position.start.offset).toBe(0);
expect(tree.children[0].position.end.offset).toBe(21);
});
});
14 changes: 7 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ export function plain(text, opts = {}, components = {}) {
if (!text) return null;
[text, opts] = setup(text, opts);

return htmlProcessor(opts)
.use(rehypeReact, {
createElement: React.createElement,
Fragment: React.Fragment,
components,
})
.processSync(text).contents;
const proc = htmlProcessor(opts).use(rehypeReact, {
createElement: React.createElement,
Fragment: React.Fragment,
components,
});

return proc.processSync(text).result;
}

/**
Expand Down
3 changes: 1 addition & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const browser = require('./jest.browser');
const common = require('./jest.common');

const unit = {
Expand Down Expand Up @@ -33,4 +32,4 @@ const unit = {
},
};

module.exports = { projects: [unit, browser] };
module.exports = { projects: [unit] };
Loading

0 comments on commit 91880c9

Please sign in to comment.