Skip to content

Commit

Permalink
#6
Browse files Browse the repository at this point in the history
  • Loading branch information
mProjectsCode committed Apr 21, 2024
1 parent 7085a62 commit 48ee460
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions exampleVault/Untitled.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```yaml
test: a
```
8 changes: 8 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ export default class ShikiPlugin extends Plugin {
this.registerMarkdownCodeBlockProcessor(
alias,
async (source, el, ctx) => {
// this is so that we leave the hidden frontmatter code block in reading mode alone
if (alias === 'yaml' && ctx.frontmatter) {
const sectionInfo = ctx.getSectionInfo(el);
if (sectionInfo && sectionInfo.lineStart === 0) {
el.addClass('shiki-hide-in-reading-mode');
}
}

const codeBlock = new CodeBlock(this, el, source, language.getDefaultLanguage(), alias, ctx);

ctx.addChild(codeBlock);
Expand Down
2 changes: 1 addition & 1 deletion styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ div.expressive-code {
}

/* Hide the frontmatter code block in reading view again */
div.markdown-preview-view > div > div.mod-header + div > div {
div.markdown-preview-view > div > div.mod-header + div > div.block-language-yaml.shiki-hide-in-reading-mode {
display: none;
}

0 comments on commit 48ee460

Please sign in to comment.