mirror of
https://github.com/stablyai/orca.git
synced 2026-11-17 03:15:01 +00:00
Require a letter after each email domain dot and keep text joins linear
An address like _a_@b.-c.com is not a GFM bare email, so emitting it bare let the underscores become emphasis; it now uses the explicit mailto link. Joining split text no longer copies the previous node on every merge. Co-authored-by: LDH1103 <ldh517525@gmail.com>
This commit is contained in:
co-authored by
LDH1103
parent
bb0e874d6d
commit
b7fc6a56ad
@@ -115,7 +115,7 @@ function supportsBareAutolink(value: string): boolean {
|
||||
const authority = /^(?:https?:\/\/|www\.)([^/?#]*)/i.exec(value)?.[1]
|
||||
if (authority === undefined) {
|
||||
// GFM's bare-email grammar is narrower than the angle-autolink local part the scanner accepts.
|
||||
return /^[-.\w+]+@[-\w]+(?:\.[-\w]+)+$/.test(value) && !/[-\d_]$/.test(value)
|
||||
return /^[-.\w+]+@[-\w]+(?:\.[A-Za-z0-9][-\w]*)+$/.test(value) && !/[-\d_]$/.test(value)
|
||||
}
|
||||
return /^[\p{L}\p{N}][\p{L}\p{N}.-]*(?::[0-9]+)?$/u.test(authority)
|
||||
}
|
||||
|
||||
@@ -160,7 +160,11 @@ function joinedTextRuns(children: unknown[]): Record<string, unknown>[] {
|
||||
const previous = runs.at(-1)
|
||||
const marks = typeof node.text === 'string' ? JSON.stringify(node.marks ?? []) : ''
|
||||
if (marks && typeof previous?.text === 'string' && marks === previousMarks) {
|
||||
runs[runs.length - 1] = { ...previous, text: previous.text + node.text }
|
||||
runs[runs.length - 1] = {
|
||||
type: 'text',
|
||||
text: previous.text + node.text,
|
||||
marks: previous.marks
|
||||
}
|
||||
} else {
|
||||
runs.push(node)
|
||||
}
|
||||
|
||||
@@ -786,10 +786,11 @@ it('keeps ambiguous URL authorities active through real Markdown read-back', asy
|
||||
href: 'http://www.foo_bar.com/'
|
||||
},
|
||||
{ text: 'http://-foo.com/', markdown: '<http://-foo.com/>', href: 'http://-foo.com/' },
|
||||
{ text: '*a*@b.com', markdown: '[\\*a\\*@b.com](mailto:*a*@b.com)', href: 'mailto:*a*@b.com' },
|
||||
{
|
||||
text: '*foo*@example.com',
|
||||
markdown: '[\\*foo\\*@example.com](mailto:*foo*@example.com)',
|
||||
href: 'mailto:*foo*@example.com'
|
||||
text: '_a_@b.-c.com',
|
||||
markdown: '[\\_a\\_@b.-c.com](mailto:_a_@b.-c.com)',
|
||||
href: 'mailto:_a_@b.-c.com'
|
||||
},
|
||||
{
|
||||
text: ['https://example.com', '/docs'],
|
||||
|
||||
Reference in New Issue
Block a user