Skip to content

Instantly share code, notes, and snippets.

@starakaj
Created February 22, 2021 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save starakaj/fe524f662ad0e0c0e74e91ceca5daab1 to your computer and use it in GitHub Desktop.
Save starakaj/fe524f662ad0e0c0e74e91ceca5daab1 to your computer and use it in GitHub Desktop.
const parser = new html2.Parser({
onopentag(name: string, attribs: {[s: string]: string}) {
if (name === "rect") {
let x = t.numericLiteral(Number.parseFloat(attribs.x || "0"));
let y = t.numericLiteral(Number.parseFloat(attribs.y || "0"));
let w = t.numericLiteral(Number.parseFloat(attribs.width || "0"));
let h = t.numericLiteral(Number.parseFloat(attribs.height || "0"));
const rectStatements = makeRectDrawStatements({ x, y, w, h });
paintStatements = paintStatements.concat(rectStatements);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment