Skip to content

Instantly share code, notes, and snippets.

@schemar
Last active April 18, 2021 16:06
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 schemar/58b79e87d4858b837b0095b46dea273f to your computer and use it in GitHub Desktop.
Save schemar/58b79e87d4858b837b0095b46dea273f to your computer and use it in GitHub Desktop.
Test Plugin with MarkdowRenderChild in CodeBlock
import { MarkdownRenderChild, Plugin } from 'obsidian';
export default class Test extends Plugin {
async onload() {
console.log('loading plugin "test"');
this.registerMarkdownCodeBlockProcessor('testlang', async (_src, el, ctx) => {
ctx.addChild(new TestRenderChild(el));
});
}
onunload() {
console.log('unloading plugin "test"');
}
}
class TestRenderChild extends MarkdownRenderChild {
private readonly container: HTMLElement;
constructor(element: HTMLElement) {
super();
this.container = element;
}
onload() {
console.log('load test');
const div = this.container.createEl('div');
div.innerHTML = 'test';
}
onunload() {
console.log('unload test');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment