Skip to content

Commit

Permalink
fix: link refs (#1010)
Browse files Browse the repository at this point in the history
[![PR App][icn]][demo] | Ref RM-10989
:-------------------:|:----------:

## 🧰 Changes

Globally replaces unnecessary escapes of emphasis characters.

## 🧬 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 Oct 30, 2024
1 parent fbe9109 commit f505402
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
20 changes: 20 additions & 0 deletions __tests__/migration/emphasis.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,24 @@ describe('migrating emphasis', () => {
"
`);
});

it('removes unneccesary escapes from emphasis', () => {
const md = `[FOO_BAR] and [FOO__BAR]`;
const mdx = migrate(md);

expect(mdx).toMatchInlineSnapshot(`
"[FOO_BAR][FOO_BAR] and [FOO__BAR][FOO__BAR]
"
`);
});

it('migrates deprecated internal emphasis', () => {
const md = `Foo__Bar__Baz`;
const mdx = migrate(md);

expect(mdx).toMatchInlineSnapshot(`
"Foo**Bar**Baz
"
`);
});
});
4 changes: 3 additions & 1 deletion lib/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import mdx from './mdx';
import mdastV6 from './mdastV6';

const migrate = (doc: string): string => {
return mdx(mdastV6(doc)).replaceAll(/ /g, ' ');
return mdx(mdastV6(doc))
.replaceAll(/ /g, ' ')
.replaceAll(/(?<!\s)\\_(?!\s)/g, '_');
};

export default migrate;

0 comments on commit f505402

Please sign in to comment.