It’s Chapbook that’s converting all straight quotes of "
and '
to the curly variety. Javier is sharing the rendered output of how Chapbook is corrupting the code, I believe. I do know that Javier submitted the bug already and Chris acknowledged it and is on it. It’s just that David suggested a solution that seems to be prone to the curly quote bug after the bug was brought to light in another thread…
Ah. Mea culpa.
Holy crap! That’s perfect! Chris really went the extra mile with his code commenting. It reads like documentation. This is awesome and overwhelming at the same time. Still have to follow the breadcrumb trail to piece it all together, but it’s there. *mind blown*
Thank you so much!
I think this is not the same bug–issue with the code is that it’s inserting the value of set
directly into HTML without escaping the quotation marks around "hello"
in the example, so it returns HTML that closes the attribute too soon: <a ... data-set="name: "hello"">
.
Here’s a tweak that works for me and also avoids the issue of having to use prependListener:
engine.extend('1.0.0', () => {
engine.event.addListener('dom-click', el => {
const setters = el.dataset.cbSetVars;
const destination = el.dataset.cbSetVarsDestination;
if (setters) {
engine.render(setters.replace(/;/g, '\n') + '\n--');
}
if (destination) {
go(destination);
}
});
config.template.inserts = [
{
match: /^set\s+link/i,
render(passage, props) {
if (passage) {
const link = document.createElement('a');
link.setAttribute('href', 'javascript:void(0)');
link.dataset.cbSetVarsDestination = passage;
link.dataset.cbSetVars = props.set;
link.innerText = props.label;
return link.outerHTML;
}
}
},
...config.template.inserts
];
});
Ahh, by creating the link directly instead of returning a textual representation of it, makes sense
It works perfectly! Thanks!!