Skip to content

Commit

Permalink
feat(#141): allow custom markers, propose default colors
Browse files Browse the repository at this point in the history
  • Loading branch information
tuurep committed Sep 18, 2024
1 parent 9b1d6be commit 6d06a12
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/parser/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ mdit.use(anchor, {
placement: 'before',
}),
});
mdit.use(githubAlerts, {
markers: '*'

Check failure on line 69 in src/parser/markdown.ts

View workflow job for this annotation

GitHub Actions / Lint

Insert `,`
});
mdit.use(graphviz);
mdit.use(githubAlerts);
mdit.use(mermaid);

const renderMarkdown: Renderer = (content: string) => {
Expand Down
4 changes: 4 additions & 0 deletions static/colors.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
--alert-warning: #ffaf00;
--alert-caution: #ff5f5f;

--alert-custom-default: #c0c0c0;

--ipynb-bg-error: rgba(255, 0, 0, 0.1);
}

Expand Down Expand Up @@ -97,6 +99,8 @@
--alert-warning: #bf8700;
--alert-caution: #cf222e;

--alert-custom-default: #404040;

--ipynb-bg-error: rgba(255, 0, 0, 0.1);
}
}
8 changes: 8 additions & 0 deletions static/markdown.css
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@ blockquote {
vertical-align: text-bottom;
fill: currentColor;
}
/* default style for custom markers (Obsidian Callout style) */
.markdown-alert {
border-left: .25rem solid var(--alert-custom-default);
}
.markdown-alert .markdown-alert-title {
color: var(--alert-custom-default);
}
/* default styles for GitHub style markers */
.markdown-alert-note {
border-left: .25rem solid var(--alert-note);
}
Expand Down
21 changes: 17 additions & 4 deletions tests/rendering/markdown-additional.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ While not a markdown syntax, this has a default style:

Press <kbd>Ctrl</kbd> + <kbd>C</kbd> to copy, and <kbd>Ctrl</kbd> + <kbd>V</kbd> to paste!

## Custom attributes
## Custom attribute

This paragraph has a red background color.{style=background-color:red}

## Github alert blockquote
## GitHub style alert

### The 5 default GitHub style alerts

> [!NOTE]
> Something to take into account
Expand All @@ -63,7 +65,18 @@ This paragraph has a red background color.{style=background-color:red}
> [!CAUTION]
> Do not do this and that!
With a custom title:
### With a custom title

> [!NOTE] Foo bar
> Hello
> 'Note' with a custom title
### Using custom markers ([Obsidian Callout](https://help.obsidian.md/Editing+and+formatting/Callouts) style)

> [!CUSTOM]
> Something more special
> [!fOoBaR]
> The marker is case-insensitive and turns into Title Case
> [!CUSTOM] paY aTtEntiOn
> You can use a custom title with a custom marker as well

0 comments on commit 6d06a12

Please sign in to comment.