Skip to content

Commit

Permalink
added block comment support
Browse files Browse the repository at this point in the history
  • Loading branch information
MSzturc committed Dec 9, 2021
1 parent 39dea37 commit 744aeac
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 3 deletions.
41 changes: 39 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ You can embed sections from your notes into your presentation

---

## Element Annotations
### Element Annotations

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

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

---

## Slide Annotations
### Slide Annotations

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

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

# Slide with green background color

---

### Block Comments

You can use block comments to group parts of your slide.

::: block

#### Header
_and_
Paragraph content
*in same block*

:::

By annotating the block all items inside this block gets the properties of the annotation:

no color

::: block <!-- .element: style="background-color: red;" -->

everything inside this block has red background color

::: block <!-- .element: style="background-color: blue;" -->

blue

:::

red

:::

no color


17 changes: 17 additions & 0 deletions src/blockProcessor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

export class BlockProcessor {

process(markdown: string){
return this.transformBlock(markdown);
}

transformBlock(markdown: string) {

markdown = markdown.replaceAll('::: block', '<div class="block">');
markdown = markdown.replaceAll(':::', '</div>');
return markdown;
}

}


6 changes: 5 additions & 1 deletion src/obsidianMarkdownPreprocessor.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import { App } from "obsidian";
import { BlockProcessor } from "./blockProcessor";
import { MultipleFileProcessor } from "./multipleFileProcessor";

export class ObsidianMarkdownPreprocessor {

private multipleFileProcessor : MultipleFileProcessor;
private blockProcessor : BlockProcessor;

constructor(app: App) {
this.multipleFileProcessor = new MultipleFileProcessor(app);
this.blockProcessor = new BlockProcessor();
}

process(markdown: string){
const afterMultipleFileProcessor = this.multipleFileProcessor.process(markdown);
return afterMultipleFileProcessor;
const afterBlockProcessor = this.blockProcessor.process(afterMultipleFileProcessor);
return afterBlockProcessor;
}


Expand Down

0 comments on commit 744aeac

Please sign in to comment.