Markdown parser, done right. 100% CommonMark support, extensions, syntax plugins & high speed
https://markdown-it.github.io/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
454 B
24 lines
454 B
// Normalize input string
|
|
|
|
'use strict';
|
|
|
|
|
|
// https://spec.commonmark.org/0.29/#line-ending
|
|
var CRLF_RE = /\r\n?/g;
|
|
|
|
|
|
module.exports = function normalize(state) {
|
|
var src = state.src;
|
|
|
|
// Normalize CRLF newlines
|
|
src = src.replace(CRLF_RE, '\n');
|
|
|
|
// Replace NULL characters
|
|
for (var i = 0, l = src.length; i < l; i++) {
|
|
if (!src.charCodeAt(i)) {
|
|
src = src.slice (0, i) + '\uFFFD' + src.slice (i + 1);
|
|
}
|
|
}
|
|
|
|
state.src = src;
|
|
};
|
|
|