Skip to content

Commit

Permalink
[autofix.ci] apply automated fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
autofix-ci[bot] authored Jan 14, 2025
1 parent 71ce291 commit cd24ba0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 27 deletions.
1 change: 0 additions & 1 deletion e2e/src/crepe/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ export const crepe = {
title: 'Crepe',
link: '/crepe/',
}

6 changes: 3 additions & 3 deletions e2e/src/crepe/main.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Crepe } from '@milkdown/crepe'
import "@milkdown/crepe/theme/common/style.css";
import "@milkdown/crepe/theme/frame.css";
import '@milkdown/crepe/theme/common/style.css'
import '@milkdown/crepe/theme/frame.css'

import { setup } from '../utils'

setup(async () => {
const crepe = new Crepe({
root: '#app',
})
await crepe.create();
await crepe.create()
return crepe.editor
})
8 changes: 4 additions & 4 deletions e2e/tests/crepe/latex.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test('latex block preview toggle', async ({ page }) => {
await expect(codeBlock).toBeVisible()

// when code block is empty, preview toggle button is not visible
await codeTools.hover();
await codeTools.hover()
await expect(previewToggleButton).not.toBeVisible()

await page.keyboard.press('ArrowUp')
Expand All @@ -29,7 +29,7 @@ test('latex block preview toggle', async ({ page }) => {
const markdown = await getMarkdown(page)
expect(markdown.trim()).toEqual('$$\nE=mc^2\n$$')

await codeTools.hover();
await codeTools.hover()
await expect(previewToggleButton).toBeVisible()

await expect(codemirror).toBeVisible()
Expand All @@ -45,8 +45,8 @@ test('latex inline', async ({ page }) => {
await page.keyboard.type('$E=mc^2$')

const inlineLatex = page.locator('span[data-type="math_inline"]')
const inlineLatexInput = page.locator('milkdown-latex-inline-edit');
const inlineLatexInputConfirm = inlineLatexInput.locator('button');
const inlineLatexInput = page.locator('milkdown-latex-inline-edit')
const inlineLatexInputConfirm = inlineLatexInput.locator('button')

await expect(inlineLatex).toBeVisible()

Expand Down
40 changes: 21 additions & 19 deletions packages/crepe/src/feature/latex/block-latex.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
import { codeBlockSchema } from "@milkdown/kit/preset/commonmark";
import { codeBlockSchema } from '@milkdown/kit/preset/commonmark'

export const blockLatexSchema = codeBlockSchema.extendSchema(
prev => {
return (ctx) => {
const baseSchema = prev(ctx)
return {
...baseSchema,
toMarkdown: {
match: baseSchema.toMarkdown.match,
runner: (state, node) => {
const language = node.attrs.language;
if (language.toLowerCase() === 'latex') {
state.addNode('math', undefined, node.content.firstChild?.text || '')
} else {
return baseSchema.toMarkdown.runner(state, node)
}
},
export const blockLatexSchema = codeBlockSchema.extendSchema((prev) => {
return (ctx) => {
const baseSchema = prev(ctx)
return {
...baseSchema,
toMarkdown: {
match: baseSchema.toMarkdown.match,
runner: (state, node) => {
const language = node.attrs.language
if (language.toLowerCase() === 'latex') {
state.addNode(
'math',
undefined,
node.content.firstChild?.text || ''
)
} else {
return baseSchema.toMarkdown.runner(state, node)
}
},
}
},
}
}
)
})

0 comments on commit cd24ba0

Please sign in to comment.