Closed saschanaz closed 5 years ago
Would be great. There is some trickiness with linking, but that could be resolved on the ReSpec side... so long as we get back the correct HTML structure, and the right IDs, can definitely work with that.
Currently I'm thinking about a writer API that doesn't directly couple with ReSpec:
import * as webidl2 from "webidl2";
import hyperHTML from "hyperhtml";
webidl2.writer(ast, {
// Customizes trivia output. The raw string will be used if absent
trivia(text) {
return hyperHTML`<span class="idlComment">${text}</span>`;
}
// Customizes type reference output
reference(name) {
return hyperHTML`<a>${name}</a>`
}
interface(obj, components) {
const idlId = ""; // ReSpec somehow generates this
return hyperHTML`<span class="idlInterface" id="${idlId}" data-idl data-title="${obj.name}">${components}</span>`;
}
// ... some more similar functions ...
});
Closed by #241
188 removed
opt
parameter forwrite
.write(ast, { type })
will use callback for every IDL type, so we can use it as a hook to add HTML class for them.I haven't really been played with ReSpec webidl writer deep enough, but I think reviving the optional callback may allow ReSpec to replace the current writer with the new webidl2.js one.