This Gist was automatically created by Carbide, a free online programming environment.
Last active
February 23, 2021 11:53
-
-
Save VLZH/59e6c9fc843deb09de09bab71c16aab6 to your computer and use it in GitHub Desktop.
Yeap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const unified = require("unified"); | |
const TEXT = "Hello %world% %yeap%"; | |
function customParser(){ | |
this.Parser = (doc) => { | |
console.log("doc", doc) | |
return { | |
type: "TEXT_NODE", | |
data: doc | |
} | |
} | |
} | |
function customCompiler(){ | |
this.Compiler = (tree) => { | |
console.log("tree", tree); | |
return "Hello!"; | |
} | |
} | |
const processor = unified() | |
.use(customParser) | |
.use((...args) => { | |
console.log("ARGS!", args); | |
}) | |
.use(customCompiler); | |
processor.processSync(TEXT); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const TEXT = "Hello %world% %yeap%"; | |
function customParser(){ | |
this.Parser = (doc) => { | |
console.log("doc", doc) | |
return { | |
type: "TEXT_NODE", | |
data: doc | |
} | |
} | |
} | |
function customCompiler(){ | |
this.Compiler = (tree) => { | |
console.log("tree", tree); | |
return "Hello!"; | |
} | |
} | |
const processor = unified() | |
.use(customParser) | |
.use((...args) => { | |
console.log("ARGS!", args); | |
}) | |
.use(customCompiler); | |
processor.processSync(TEXT); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment