Skip to content

Commit

Permalink
Merge pull request #788 from tsa321/codeFenceRegMatching
Browse files Browse the repository at this point in the history
Allow codefence regex to accept any characters after first three backticks
  • Loading branch information
AndrewGable authored Sep 4, 2024
2 parents 331f535 + 9ebe94f commit 49e7119
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
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

0 comments on commit 49e7119

Please sign in to comment.