markdown-it / markdown-it-cjk-breaks

Suppress linebreaks between east asian characters
https://markdown-it.github.io
MIT License
20 stars 7 forks source link

Exception is thrown when a softbreak token is not surrounded by text-tokens #2

Closed yamavol closed 5 years ago

yamavol commented 5 years ago

This script

var md = require('markdown-it')();
var cjk = require('markdown-it-cjk-breaks')
var text = '![img](image.png)\ntext';
var conv = md.use(cjk).render(text)
console.log(conv);

throws an exception

TypeError: character.charCodeAt is not a function

This is because the plugin tries to runeastAsianWidth(last) in line55 even if last is not modified from 0x20. Here it the token-array when the exception was thrown.

image

rlidwka commented 5 years ago

Yeah last should always be a character, not a charcode.

Fixed, thanks for reporting.