Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow codefence regex to accept any characters after first three backticks #788

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions __tests__/ExpensiMark-HTML-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,12 @@ test('Test code fencing with spaces and new lines', () => {
codeFenceExample = '```\r\n# test\r\n```';
expect(parser.replace(codeFenceExample)).toBe('<pre>#&#32;test<br /></pre>');

codeFenceExample = '``` \r\n# test\r\n```';
expect(parser.replace(codeFenceExample)).toBe('<pre>#&#32;test<br /></pre>');

codeFenceExample = '```test\r\n# test\r\n```';
expect(parser.replace(codeFenceExample)).toBe('<pre>#&#32;test<br /></pre>');

codeFenceExample = '```\r\n\r\n# test\r\n\r\n```';
expect(parser.replace(codeFenceExample)).toBe('<pre><br />#&#32;test<br /><br /></pre>');

Expand Down
2 changes: 1 addition & 1 deletion lib/ExpensiMark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export default class ExpensiMark {
name: 'codeFence',

// &#x60; is a backtick symbol we are matching on three of them before then after a new line character
regex: /(&#x60;&#x60;&#x60;(\r\n|\n))((?:\s*?(?!(?:\r\n|\n)?&#x60;&#x60;&#x60;(?!&#x60;))[\S])+\s*?(?:\r\n|\n))(&#x60;&#x60;&#x60;)/g,
regex: /(&#x60;&#x60;&#x60;.*?(\r\n|\n))((?:\s*?(?!(?:\r\n|\n)?&#x60;&#x60;&#x60;(?!&#x60;))[\S])+\s*?(?:\r\n|\n))(&#x60;&#x60;&#x60;)/g,

// We're using a function here to perform an additional replace on the content
// inside the backticks because Android is not able to use <pre> tags and does
Expand Down
Loading