Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom alert markers (for Obsidian Callout style alert) #185

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: '*',
});
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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if it actually is "Title Case",
However since multi-word markers don't currently work in the plugin, it's not super relevant at the moment

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed that in Obsidian it's like this:

> [!hello world]

gives Hello world so first letter capitalized only


> [!CUSTOM] paY aTtEntiOn
> You can use a custom title with a custom marker as well