Skip to content

Commit

Permalink
fix inline codeblock with two backticks
Browse files Browse the repository at this point in the history
  • Loading branch information
Antasel committed Aug 17, 2023
1 parent 4cc5f72 commit f3fd643
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions __tests__/ExpensiMark-HTML-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,11 @@ test('Test inline code blocks inside ExpensiMark', () => {
expect(parser.replace(testString)).toBe(resultString);
});

test('Test inline code blocks with two backticks', () => {
const testString = '``JavaScript``';
expect(parser.replace(testString)).toBe('<code>&#x60;JavaScript&#x60;</code>');
});

test('Test code fencing with ExpensiMark syntax inside', () => {
let codeFenceExample = '```\nThis is how you can write ~strikethrough~, *bold*, _italics_, and [links](https://www.expensify.com)\n```';
expect(parser.replace(codeFenceExample)).toBe('<pre>This&#32;is&#32;how&#32;you&#32;can&#32;write&#32;~strikethrough~,&#32;*bold*,&#32;_italics_,&#32;and&#32;[links](https://www.expensify.com)<br /></pre>');
Expand Down
2 changes: 1 addition & 1 deletion lib/ExpensiMark.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default class ExpensiMark {

// Use the url escaped version of a backtick (`) symbol. Mobile platforms do not support lookbehinds,
// so capture the first and third group and place them in the replacement.
regex: /(\B|_|)&#x60;(.*?\S.*?)&#x60;(\B|_|)(?![^<]*<\/pre>)/g,
regex: /(\B|_|)&#x60;(.*?\S.*?)&#x60;(\B|_|)(?!&#x60;|[^<]*<\/pre>)/g,
replacement: '$1<code>$2</code>$3',
},

Expand Down

0 comments on commit f3fd643

Please sign in to comment.