Skip to content

Commit 48ee460

Browse files
committed
1 parent 7085a62 commit 48ee460

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

exampleVault/Untitled.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
```yaml
2+
test: a
3+
```
4+

src/main.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,14 @@ export default class ShikiPlugin extends Plugin {
175175
this.registerMarkdownCodeBlockProcessor(
176176
alias,
177177
async (source, el, ctx) => {
178+
// this is so that we leave the hidden frontmatter code block in reading mode alone
179+
if (alias === 'yaml' && ctx.frontmatter) {
180+
const sectionInfo = ctx.getSectionInfo(el);
181+
if (sectionInfo && sectionInfo.lineStart === 0) {
182+
el.addClass('shiki-hide-in-reading-mode');
183+
}
184+
}
185+
178186
const codeBlock = new CodeBlock(this, el, source, language.getDefaultLanguage(), alias, ctx);
179187

180188
ctx.addChild(codeBlock);

styles.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,6 @@ div.expressive-code {
7878
}
7979

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

0 commit comments

Comments
 (0)