chrisweb / rehype-github-alerts Goto Github PK
View Code? Open in Web Editor NEWrehype plugin to create alerts (admonitions/callouts), mimicking the way alerts get rendered on github.com
License: MIT License
rehype plugin to create alerts (admonitions/callouts), mimicking the way alerts get rendered on github.com
License: MIT License
v1.x has a bug where content of alerts like a list don't get displayed correctly
something like the following markdown was not displaying correctly in v1.x:
# note with a list
> [!NOTE]
> - foo
> - bar
Thanks for this library Chris!
It would be great if we allowed custom titles like Obsidian does.
> [!INFO] Why **CDK**?
> AWS CDK (Cloud Development Kit) is the easiest and faster way to get your AWS Lambda code up and running
Right now it gets rendered as a quote only instead of the alert:
[!INFO] Why CDK?
AWS CDK (Cloud Development Kit) is the easiest and faster way to get your AWS Lambda code up and running
Note
this is an example "note" (with two spaces after "[!NOTE]")
> [!NOTE]
> this is an example "note" (with two spaces after "[!NOTE]")
Important
this is an example "important" (with NO spaces after "[!IMPORTANT]")
> [!IMPORTANT]
> this is an example "important" (with NO spaces after "[!IMPORTANT]")
Note
this is an example "note" (with two spaces after "[!NOTE]") and a second line of content, containing a "strong" element and a link
foo top
> [!NOTE]
> this is an example "note" (with two spaces after "[!NOTE]") and a second line of content, containing a "strong" element and a link
> **foo** [top](#rehype-github-alerts-test)
Important
this is an example "important" (with NO spaces after "[!IMPORTANT]") and a second line of content, containing a "strong" element and a link
foo top
> [!IMPORTANT]
> this is an example "important" (with NO spaces after "[!IMPORTANT]") and a second line of content, containing a "strong" element and a link
> **foo** [top](#rehype-github-alerts-test)
Warning
[!IMPORTANT]
test for nested alerts
> [!WARNING]
>> [!IMPORTANT]
>> test for nested alerts
NOTE
test for legacy alerts
> **NOTE**
> test for legacy alerts
NOTE
test for legacy alerts with second line
foo top
> **NOTE**
> test for legacy alerts with second line
> **foo** [top](#rehype-github-alerts-test)
[!NOTE]
test for nested blockquotes
>>> [!NOTE]
>>> test for nested blockquotes
[!INVALID]
test for invalid alert type
> [!INVALID]
> test for invalid alert type
Thanks for this repo!
It Might be worth updating the readme to specify /why/ you need remarkBreaks.... because otherwise it wont work unless you put two spaces.
I Spent some time (10 mins) trying to debug this, downloading and testing the example repo, assuming the parser wasnt working properly before I went back and understood exactly why your test code has 2 spaces in it.
Hi, I'm having troubles making your plugin work, here is a screenshot of what's the result:
As you can see it gets rendered as a blockquote
Where the markdown code is the following:
In the given sentence, унитазу
refers to toilet
.
Type | Transliteration |
---|---|
Cyrillic | унитаз |
Latin | unitazu |
The word унитаз
generally means toilet
or lavatory
. It specifically refers to the fixture used for urination and defecation.
Я купил новый унитаз для ванной комнаты.
I bought a new toilet for the bathroom.
Унитаз засорился, и нам пришлось вызвать сантехника.
The toilet got clogged, and we had to call a plumber.
Перед тем как покрасить ванную комнату, нам нужно снять крышку унитаза.
Before painting the bathroom, we need to remove the toilet seat.
Note
In Russian, nouns have cases. The word "унитаз" in this context is in the Dative case due to its prepositional use with "к" (to, towards), indicating direction or proximity.
Cas | Singular |
---|---|
Nominative | унитаз (unitaz) |
Accusative | унитаз (unitaz) |
Genitive | унитаза (unitaza) |
Dative | унитазу (unitazu) |
Instrumental | унитазом (unitazom) |
Prepositional | об унитазе (o unitaze) |
Here is the tsx code:
import type { TranslationPopoverProps } from '@common/components/word/translation-popover.component'
import { useExplanationRequestStore } from '@common/stores/explanation-request.store'
import Markdown from 'react-markdown'
import remarkGfm from 'remark-gfm'
import { rehypeGithubAlerts } from 'rehype-github-alerts'
export function ExplanationComponent(props: TranslationPopoverProps) {
const explanationRequest = useExplanationRequestStore((state) =>
state.requests.get(props.requestID),
)
const explanation = explanationRequest?.explanation
if (explanation?.length === 0 || !explanation) {
return null
}
return (
<div className="markdown-body size-full overflow-y-auto rounded-md p-1 px-2.5 text-left font-fluent text-base text-white">
<Markdown remarkPlugins={[rehypeGithubAlerts, remarkGfm]}>
{explanation}
</Markdown>
</div>
)
}
and my style.css:
@import 'github-markdown-css/github-markdown.css';
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer Components {
:root {
--blue: #4285f4;
--purple: #9b72cb;
--red: #d96570;
--input: 214.3 31.8% 91.4%;
--ring: 215 20.2% 65.1%;
--github-alert-default-color: rgb(175, 184, 193);
--github-alert-note-color: rgb(9, 105, 218);
--github-alert-important-color: rgb(130, 80, 223);
--github-alert-warning-color: rgb(154, 103, 0);
}
.markdown-alert {
padding: 0 1em;
margin-bottom: 16px;
border-left: 0.25em solid var(--github-alert-default-color);
}
.markdown-alert-note {
border-left-color: var(--github-alert-note-color);
}
.markdown-alert-important {
border-left-color: var(--github-alert-important-color);
}
.markdown-alert-warning {
border-left-color: var(--github-alert-warning-color);
}
.markdown-alert-header {
display: inline-flex;
margin-bottom: 4px;
align-items: center;
}
.markdown-alert-header > svg {
margin-right: 8px;
}
```
Thanks a lot in advance for your help !!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.