Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"preview": "vite preview",
"serve": "serve lib --listen 4173 -L",
"test": "playwright test",
"test:debug": "playwright test --ui",
"test:install": "playwright install --with-deps"
},
"dependencies": {
Expand Down
13 changes: 12 additions & 1 deletion e2e/tests/input/strike-through.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, test } from '@playwright/test'

import { focusEditor } from '../misc'
import { focusEditor, getMarkdown } from '../misc'

test.beforeEach(async ({ page }) => {
await page.goto('/preset-gfm/')
Expand All @@ -12,3 +12,14 @@ test('strike through', async ({ page }) => {
await page.keyboard.type('The lunatic is ~~on the grass~~')
await expect(editor.locator('del')).toHaveText('on the grass')
})

test('intra-word strike through', async ({ page }) => {
const editor = page.locator('.editor')
await focusEditor(page)
await page.keyboard.type('C:/the/~lunatic~/is/on/the/grass')
await expect(editor.locator('del')).toHaveCount(0)

const markdown = await getMarkdown(page)

expect(markdown).toBe('C:/the/\\~lunatic\\~/is/on/the/grass\n')
})
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"test:lint": "oxlint -c .oxlintrc.json",
"test:eslint": "eslint . --cache",
"test:e2e": "pnpm --filter=@milkdown/e2e test",
"test:e2e:debug": "pnpm --filter=@milkdown/e2e run test:debug",
"test:e2e:build": "pnpm --filter=@milkdown/e2e run build",
"format": "lint-staged",
"fix": "prettier . --write",
Expand Down
5 changes: 4 additions & 1 deletion packages/plugins/preset-gfm/src/mark/strike-through.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ withMeta(toggleStrikethroughCommand, {

/// Input rule to create the strikethrough mark.
export const strikethroughInputRule = $inputRule((ctx) => {
return markRule(/~([^~]+)~$/, strikethroughSchema.type(ctx))
return markRule(
/(?<![\w:/])(~{1,2})(.+?)\1(?!\w|\/)/,
strikethroughSchema.type(ctx)
)
})

withMeta(strikethroughInputRule, {
Expand Down
Loading