Skip to content

Commit

Permalink
fix: migration issues (#896)
Browse files Browse the repository at this point in the history
| [![PR App][icn]][demo] | Fix RM-XYZ |
| :--------------------: | :--------: |

## 🧰 Changes

Fixes some issus that come up during testing.

1. Close unclosed self-closing tags.
2. Handle mutli-line html comments.

## 🧬 QA & Testing

- [Broken on production][prod].
- [Working in this PR app][demo].

[demo]: https://markdown-pr-PR_NUMBER.herokuapp.com
[prod]: https://SUBDOMAIN.readme.io
[icn]:
https://user-images.githubusercontent.com/886627/160426047-1bee9488-305a-4145-bb2b-09d8b757d38a.svg
  • Loading branch information
kellyjosephprice authored Jun 4, 2024
1 parent e0e3e8e commit 9752849
Show file tree
Hide file tree
Showing 4 changed files with 2,076 additions and 188 deletions.
56 changes: 51 additions & 5 deletions __tests__/compilers/compatability.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { mdx } from '../../index';
import * as rdmd from '@readme/markdown-legacy';

describe('compatability with RDMD', () => {
it('compiles variable nodes', () => {
Expand Down Expand Up @@ -51,11 +52,56 @@ describe('compatability with RDMD', () => {
});

it('compiles html comments to JSX comments', () => {
const ast = {
type: 'html',
value: '<!-- commentable -->',
};
const md = `
This is some in progress <!-- commented out stuff -->
`;

expect(mdx(rdmd.mdast(md)).trim()).toBe('This is some in progress {/* commented out stuff */}');
});

it('compiles multi-line html comments to JSX comments', () => {
const md = `
## Wip
<!--
### Some stuff I was working on
-->
`;

expect(mdx(rdmd.mdast(md)).trim()).toMatchInlineSnapshot(`
"## Wip
{/*
### Some stuff I was working on
*/}"
`);
});

it('closes un-closed self closing tags', () => {
const md = `
This is a break: <br>
`;

expect(mdx(rdmd.mdast(md)).trim()).toBe('This is a break: <br />');
});

it('closes un-closed self closing tags with a space', () => {
const md = `
This is a break: <br >
`;

expect(mdx(rdmd.mdast(md)).trim()).toBe('This is a break: <br />');
});

it('closes complex un-closed self closing tags', () => {
const md = `
This is an image: <img src="http://example.com/#\\>" >
`;

expect(mdx(ast).trim()).toBe('{/* commentable */}');
expect(mdx(rdmd.mdast(md)).trim()).toBe('This is an image: <img src="http://example.com/#\\>" />');
});
});
Loading

0 comments on commit 9752849

Please sign in to comment.