-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1935 from ZeroX-DG/allow-no-html-escape
Allow customizing html escape when export note
- Loading branch information
Showing
4 changed files
with
102 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -251,4 +251,3 @@ class Markdown { | |
} | ||
|
||
export default Markdown | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const { escapeHtmlCharacters } = require('browser/lib/utils') | ||
const test = require('ava') | ||
|
||
test('escapeHtmlCharacters should return the original string if nothing needed to escape', t => { | ||
const input = 'Nothing to be escaped' | ||
const expected = 'Nothing to be escaped' | ||
const actual = escapeHtmlCharacters(input) | ||
t.is(actual, expected) | ||
}) | ||
|
||
test('escapeHtmlCharacters should skip code block if that option is enabled', t => { | ||
const input = ` <no escape> | ||
<escapeMe>` | ||
const expected = ` <no escape> | ||
<escapeMe>` | ||
const actual = escapeHtmlCharacters(input, { detectCodeBlock: true }) | ||
t.is(actual, expected) | ||
}) | ||
|
||
test('escapeHtmlCharacters should NOT skip character not in code block but start with 4 spaces', t => { | ||
const input = '4 spaces &' | ||
const expected = '4 spaces &' | ||
const actual = escapeHtmlCharacters(input, { detectCodeBlock: true }) | ||
t.is(actual, expected) | ||
}) | ||
|
||
test('escapeHtmlCharacters should NOT skip code block if that option is NOT enabled', t => { | ||
const input = ` <no escape> | ||
<escapeMe>` | ||
const expected = ` <no escape> | ||
<escapeMe>` | ||
const actual = escapeHtmlCharacters(input) | ||
t.is(actual, expected) | ||
}) | ||
|
||
test('escapeHtmlCharacters should NOT escape & character if it\'s a part of an escaped character', t => { | ||
const input = 'Do not escape & or " but do escape &' | ||
const expected = 'Do not escape & or " but do escape &' | ||
const actual = escapeHtmlCharacters(input) | ||
t.is(actual, expected) | ||
}) | ||
|
||
test('escapeHtmlCharacters should return the correct result', t => { | ||
const input = '& < > " \'' | ||
const expected = '& < > " '' | ||
const actual = escapeHtmlCharacters(input) | ||
t.is(actual, expected) | ||
}) |