Open UltraCakeBakery opened 9 months ago
I believe the error must be thrown by the validator. So you can disable validator. Can you share your sample XML please?
I'm parsing a superset of HTML; see below for snippet.
The error is thrown by the util.js
isName
function, which is used by the parser. I do not see any option to disable validation. I do not use the validator explicitly. I'm just using the Parser and Builder.
<html>
<div $banana="🍌"></div>
</html>
For now I worked around this by modifying my node_modules, but that is not maintainable solution in the long run.
const nameStartChar = ':A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD@\$'; // Note the additional @ and $ I added to fit my needs.
Preferably an option which I can pass to the XML parser gets added where I can specify more characters to be valid in the attribute name.
When you're calling parse
method, are you passing any 2nd argument?
Yes;
const config = {
allowBooleanAttributes: true,
alwaysCreateTextNode: true,
preserveOrder: true,
parseAttributeValue: false,
htmlEntities: false,
isArray: true,
attributeNamePrefix: '',
ignoreAttributes: false,
unpairedTags: ["hr", "br", "link", "meta"],
stopNodes : [ "*.pre", "*.script"],
processEntities: false,
}
You shared the config. I was asking what 2nd parameter you're passing in parse method?
Sorry, I misunderstood your question; this is what I pass to the second parameter in the parse method:
{ allowBooleanAttributes: true }
pass false
as 2nd parameter and try
I want to parse markup where there are
$
and other characters in the attribute names. How can I add these characters? Is there already an option?Right now the parser throws:
Error: Attribute '$banana' is an invalid name