diff --git a/src/main.ts b/src/main.ts index 3b8f50f..57a88bf 100644 --- a/src/main.ts +++ b/src/main.ts @@ -16,6 +16,19 @@ export default class MeldBuildPlugin extends Plugin { settings: MeldBuildPluginSettings; + private async codeblockProcessor(el: HTMLElement, ctx: MarkdownPostProcessorContext): Promise { + const els = el.querySelector('.language-js'); + + if ( els == null ){ + return; + } + + if ( els.getText().contains( '//@hide_when_reading' ) ){ + console.debug('Hiding element',{el}); + el.hide(); + } + } + async onload() { await this.loadSettings(); @@ -29,6 +42,7 @@ export default class MeldBuildPlugin extends Plugin { ( source: string, el: HTMLElement, ctx: MarkdownPostProcessorContext ) => this.processToolbarRender( source, el, ctx ) ); + this.registerMarkdownPostProcessor( this.codeblockProcessor ); this.addCommand({ id: 'run', @@ -195,3 +209,4 @@ class ToolbarButton{ return null; } } + diff --git a/styles.css b/styles.css index 3c8adb6..8f0f1a8 100644 --- a/styles.css +++ b/styles.css @@ -4,4 +4,8 @@ grid-row-gap: 1em; grid-auto-flow: column; justify-content: start; +} + +.markdown-reading-view .block-language-meld-build-toolbar{ + padding:0.5em 0; } \ No newline at end of file