mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-21 09:38:01 +02:00
This commit is contained in:
parent
53d5cf55bc
commit
ff1f1b190e
@ -40,6 +40,30 @@ describe('htmlUtils', () => {
|
||||
'<img onerror="http://downloadmalware.com"/>',
|
||||
'<img onerror="http://downloadmalware.com"/>',
|
||||
],
|
||||
[
|
||||
'Some text indented by a tab:\n\tIndented',
|
||||
'<p>Some text indented by a tab:<br/> Indented</p>',
|
||||
],
|
||||
[
|
||||
'Some text indented by two spaces:\n Indented',
|
||||
'<p>Some text indented by two spaces:<br/> Indented</p>',
|
||||
],
|
||||
[
|
||||
'Some text with white space between the content\nNewLine',
|
||||
'<p>Some text with white space between the content<br/>NewLine</p>',
|
||||
],
|
||||
[
|
||||
'Some text with \t tab\nNewLine',
|
||||
'<p>Some text with \t tab<br/>NewLine</p>',
|
||||
],
|
||||
[
|
||||
'Tab at the end of the line is ignored\t\nNewLine',
|
||||
'<p>Tab at the end of the line is ignored<br/>NewLine</p>',
|
||||
],
|
||||
[
|
||||
'White space at the end of the line is ignored \nNewLine',
|
||||
'<p>White space at the end of the line is ignored<br/>NewLine</p>',
|
||||
],
|
||||
];
|
||||
|
||||
for (const t of testCases) {
|
||||
|
@ -188,7 +188,7 @@ export function plainTextToHtml(plainText: string): string {
|
||||
let currentLine = '';
|
||||
|
||||
for (let line of lines) {
|
||||
line = line.trim();
|
||||
line = line.trimEnd();
|
||||
if (!line) {
|
||||
if (currentLine) {
|
||||
step1.push(`<p>${currentLine}</p>`);
|
||||
|
@ -219,7 +219,9 @@ export function escapeHtml(s: string) {
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''');
|
||||
.replace(/'/g, ''')
|
||||
.replace(/^ +/g, match => ' '.repeat(match.length))
|
||||
.replace(/^\t+/g, match => ' '.repeat(match.length));
|
||||
}
|
||||
|
||||
// keywords can either be a list of strings, or a list of objects with the format:
|
||||
|
Loading…
Reference in New Issue
Block a user