This commit is contained in:
40
node_modules/micromark/dist/util/serialize-chunks.js
generated
vendored
Normal file
40
node_modules/micromark/dist/util/serialize-chunks.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
'use strict'
|
||||
|
||||
var fromCharCode = require('../constant/from-char-code.js')
|
||||
|
||||
function serializeChunks(chunks) {
|
||||
var index = -1
|
||||
var result = []
|
||||
var chunk
|
||||
var value
|
||||
var atTab
|
||||
|
||||
while (++index < chunks.length) {
|
||||
chunk = chunks[index]
|
||||
|
||||
if (typeof chunk === 'string') {
|
||||
value = chunk
|
||||
} else if (chunk === -5) {
|
||||
value = '\r'
|
||||
} else if (chunk === -4) {
|
||||
value = '\n'
|
||||
} else if (chunk === -3) {
|
||||
value = '\r' + '\n'
|
||||
} else if (chunk === -2) {
|
||||
value = '\t'
|
||||
} else if (chunk === -1) {
|
||||
if (atTab) continue
|
||||
value = ' '
|
||||
} else {
|
||||
// Currently only replacement character.
|
||||
value = fromCharCode(chunk)
|
||||
}
|
||||
|
||||
atTab = chunk === -2
|
||||
result.push(value)
|
||||
}
|
||||
|
||||
return result.join('')
|
||||
}
|
||||
|
||||
module.exports = serializeChunks
|
||||
Reference in New Issue
Block a user