Skip to content

Commit 88ab2c2

Browse files
committed
feat: support backslash before bracket, fix #8
1 parent 70dbe3e commit 88ab2c2

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const MarkdownItGitHubAlerts: MarkdownIt.PluginWithOptions<MarkdownItGitHubAlert
5555
} = options
5656

5757
const markerNameRE = markers === '*' ? '\\w+' : markers.join('|')
58-
const RE = new RegExp(`^\\[\\!(${markerNameRE})\\]([^\\n\\r]*)`, matchCaseSensitive ? '' : 'i')
58+
const RE = new RegExp(`^\\\\?\\[\\!(${markerNameRE})\\]([^\\n\\r]*)`, matchCaseSensitive ? '' : 'i')
5959

6060
md.core.ruler.after('block', 'github-alerts', (state) => {
6161
const tokens = state.tokens

test/fixtures.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ ${cssBase}
2323
`
2424

2525
describe('fixtures', () => {
26-
const files = import.meta.glob('./input/*.md', { as: 'raw', eager: true })
26+
const files = import.meta.glob<string>('./input/*.md', { query: '?raw', eager: true, import: 'default' })
2727
const filter = process.env.FILTER
2828
Object.entries(files)
2929
.forEach(([path, content]) => {
@@ -47,7 +47,7 @@ describe('fixtures', () => {
4747
`<style>${CSS}</style>`,
4848
].join('\n').trim().replace(/\r\n/g, '\n')
4949

50-
expect(rendered)
50+
await expect(rendered)
5151
.toMatchFileSnapshot(path.replace('input', 'output').replace('.md', '.html'))
5252
})
5353
})

test/input/1.basic.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
> [!IMPORTANT]
1010
> Crucial information necessary for users to succeed.
1111
12-
> [!WARNING]
12+
> \[!WARNING]
1313
> Critical content demanding immediate user attention due to potential risks.
1414
1515
> [!CAUTION]

0 commit comments

Comments
 (0)