Skip to content

Commit 744aeac

Browse files
committed
added block comment support
1 parent 39dea37 commit 744aeac

File tree

3 files changed

+61
-3
lines changed

3 files changed

+61
-3
lines changed

README.md

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ You can embed sections from your notes into your presentation
144144

145145
---
146146

147-
## Element Annotations
147+
### Element Annotations
148148

149149
You can pass style or class properties for an element by annotating it:
150150

@@ -156,7 +156,7 @@ You can pass style or class properties for an element by annotating it:
156156

157157
---
158158

159-
## Slide Annotations
159+
### Slide Annotations
160160

161161
You can pass style or class properties for the whole slide by annotating it:
162162

@@ -169,3 +169,40 @@ You can pass style or class properties for the whole slide by annotating it:
169169
<!-- .slide: style="background-color: green;" -->
170170

171171
# Slide with green background color
172+
173+
---
174+
175+
### Block Comments
176+
177+
You can use block comments to group parts of your slide.
178+
179+
::: block
180+
181+
#### Header
182+
_and_
183+
Paragraph content
184+
*in same block*
185+
186+
:::
187+
188+
By annotating the block all items inside this block gets the properties of the annotation:
189+
190+
no color
191+
192+
::: block <!-- .element: style="background-color: red;" -->
193+
194+
everything inside this block has red background color
195+
196+
::: block <!-- .element: style="background-color: blue;" -->
197+
198+
blue
199+
200+
:::
201+
202+
red
203+
204+
:::
205+
206+
no color
207+
208+

src/blockProcessor.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
export class BlockProcessor {
3+
4+
process(markdown: string){
5+
return this.transformBlock(markdown);
6+
}
7+
8+
transformBlock(markdown: string) {
9+
10+
markdown = markdown.replaceAll('::: block', '<div class="block">');
11+
markdown = markdown.replaceAll(':::', '</div>');
12+
return markdown;
13+
}
14+
15+
}
16+
17+

src/obsidianMarkdownPreprocessor.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
import { App } from "obsidian";
2+
import { BlockProcessor } from "./blockProcessor";
23
import { MultipleFileProcessor } from "./multipleFileProcessor";
34

45
export class ObsidianMarkdownPreprocessor {
56

67
private multipleFileProcessor : MultipleFileProcessor;
8+
private blockProcessor : BlockProcessor;
79

810
constructor(app: App) {
911
this.multipleFileProcessor = new MultipleFileProcessor(app);
12+
this.blockProcessor = new BlockProcessor();
1013
}
1114

1215
process(markdown: string){
1316
const afterMultipleFileProcessor = this.multipleFileProcessor.process(markdown);
14-
return afterMultipleFileProcessor;
17+
const afterBlockProcessor = this.blockProcessor.process(afterMultipleFileProcessor);
18+
return afterBlockProcessor;
1519
}
1620

1721

0 commit comments

Comments
 (0)