@parcel/markdown-ansi
Advanced tools
Comparing version 2.0.0-alpha.3.1 to 2.0.0-beta.1
@@ -17,3 +17,3 @@ "use strict"; | ||
const ITALIC_REGEX = /\*([^*]+)\*|_([^_]+)_/g; | ||
const ITALIC_REGEX = /(?<!\\)\*(.+)(?<!\\)\*|(?<!\\)_(.+)(?<!\\)_/g; | ||
@@ -25,3 +25,4 @@ function markdownParser(input) { | ||
input = input.replace(ITALIC_REGEX, (...args) => _chalk.default.italic(args[1] || args[2])); | ||
input = input.replace(/(?<!\\)\\/g, ''); | ||
return input; | ||
} |
{ | ||
"name": "@parcel/markdown-ansi", | ||
"version": "2.0.0-alpha.3.1", | ||
"version": "2.0.0-beta.1", | ||
"description": "Blazing fast, zero configuration web application bundler", | ||
@@ -21,3 +21,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "291f3e6815a1a857a6165fafb1691ceeb878b8f6" | ||
"gitHead": "74335525be92e23bac4ed1bf30595443cfb238e3" | ||
} |
@@ -10,3 +10,3 @@ // @flow | ||
// single char markdown matchers | ||
const ITALIC_REGEX = /\*([^*]+)\*|_([^_]+)_/g; | ||
const ITALIC_REGEX = /(?<!\\)\*(.+)(?<!\\)\*|(?<!\\)_(.+)(?<!\\)_/g; | ||
@@ -17,9 +17,10 @@ export default function markdownParser(input: string): string { | ||
input = input.replace(STRIKETHROUGH_REGEX, (...args) => | ||
chalk.strikethrough(args[1]) | ||
chalk.strikethrough(args[1]), | ||
); | ||
input = input.replace(ITALIC_REGEX, (...args) => | ||
chalk.italic(args[1] || args[2]) | ||
chalk.italic(args[1] || args[2]), | ||
); | ||
input = input.replace(/(?<!\\)\\/g, ''); | ||
return input; | ||
} |
@@ -30,2 +30,12 @@ import assert from 'assert'; | ||
}); | ||
it('should support escape character', () => { | ||
let res = mdAnsi('\\*\\*bold\\*\\* \\\\escape\\\\'); | ||
assert.equal(res, '**bold** \\escape\\'); | ||
}); | ||
it('should support italic with escape character', () => { | ||
let res = mdAnsi('\\__italic_\\_'); | ||
assert.equal(res, '_\u001b[3mitalic\u001b[23m_'); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4638
70
5