lalalic/docx2html

Failed to parse the rule '#A .1{}'.

microkof opened this issue · 2 comments

Uncaught (in promise) DOMException: Failed to execute 'insertRule' on 'CSSStyleSheet': Failed to parse the rule '#A .1{}'.

This error will occur in some files, for example: https://hebeieditor.sinaapp.com/ex.docx

Some docx files can contain styles with id started with digits.
CSS styles can't start with digits.

To solve this issue you need edit file convert.js at line 88 or edit file index.js at line 12725
from

	value: function asCssID(a) {
		return a.replace(/\s+/g, '_');
	}

to

        value: function asCssID(a) {
             var id = a.replace(/\s+/g, '_');
             if (id.match(/^\d/)) id = 'digit-' + id;
             return id;
        }

thanks, fixed it as
static asCssID(a){
return a.replace(/\s+/g,'').replace(/^\d/g,d=>""+d)
}