Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
Keep an email link's address when an underscore follows it (#7675)
Dimitri POSTOLOV8ee138c3bead
diff --git a/.changeset/email-link-before-underscore.md b/.changeset/email-link-before-underscore.mdnew file mode 100644index 000000000..e5d69c87b--- /dev/null+++ b/.changeset/email-link-before-underscore.md@@ -0,0 +1,5 @@+---+'@inkeep/open-knowledge': patch+---++An email link followed directly by an underscore, such as `[email protected]` before `_case`, now saves in a form that opens again as the same link. Before, the file opened as a link to a different address.diff --git a/packages/app/tests/stress/paste-fidelity.e2e.ts b/packages/app/tests/stress/paste-fidelity.e2e.tsindex f4d9b0273..e137578ad 100644--- a/packages/app/tests/stress/paste-fidelity.e2e.ts+++ b/packages/app/tests/stress/paste-fidelity.e2e.ts@@ -5,6 +5,7 @@ import { fileURLToPath } from 'node:url';import type { Page } from '@playwright/test';import {expect,+ placeCaretAtEndOfText,selectAllAndWaitForSelection,selectText,simulateCopyAndRead,@@ -1606,7 +1607,7 @@ test.describe('cell-insertion gate — component paste into a table cell (persis});});-const INLINE_PASTE_SEED = '- fooo\n\n## alpha\n';+const INLINE_PASTE_SEED = '- fooo\n\n## alpha\n\nMail _case\n';async function openNewEmptyBullet(page: Page): Promise<void> {await setListItemCaret(page, 0, 'end');@@ -1696,4 +1697,12 @@ test.describe('inline paste stays in the block at the caret (persisted bytes)',await pasteWithMimes(page, { 'text/plain': 'foo', 'text/html': '<b>foo</b>' });await expect.poll(() => getYText(page), { timeout: 8_000 }).toContain('## al**foo**pha');});++ test('an email pasted right before an underscore keeps its address', async ({ page }) => {+ await placeCaretAtEndOfText(page, 'Mail ');+ await pasteText(page, '[email protected]');+ await expect+ .poll(() => getYText(page), { timeout: 8_000 })+ .toContain('Mail [[email protected]](mailto:[email protected])\\_case\n');+ });});diff --git a/packages/core/src/markdown/to-markdown-handlers.ts b/packages/core/src/markdown/to-markdown-handlers.tsindex 4d54465be..83369744d 100644--- a/packages/core/src/markdown/to-markdown-handlers.ts+++ b/packages/core/src/markdown/to-markdown-handlers.ts@@ -186,9 +186,8 @@ export const toMarkdownHandlers = {const literal = onlyChild.value;const form = gfmLiteralForm(literal, node.url);if (form === undefined) return literal;- if (bareGfmLiteralReadsBack(form, literalNeighborCodes(node, parent, state, info))) {- return literal;- }+ const neighbors = literalNeighborCodes(literal, node, parent, state, info);+ if (bareGfmLiteralReadsBack(form, neighbors)) return literal;if (form === 'protocol' && readsBackAsAngleAutolink(literal)) return `<${literal}>`;}}@@ -895,6 +894,7 @@ interface NeighborCodes {}function literalNeighborCodes(+ literal: string,node: Link,parent: Parents | undefined,state: State,@@ -910,7 +910,7 @@ function literalNeighborCodes(? info.after: state.handle(next, parent, state, {...state.createTracker(info).current(),- before: '',+ before: literal,after: '',});return {