mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-12-23 08:47:50 +00:00
feat: recursively parse markup link according to typst syntax (#911)
This commit is contained in:
parent
6fa07b6777
commit
8b495fe2ab
6 changed files with 66 additions and 9 deletions
|
|
@ -312,8 +312,7 @@ const markup: textmate.Pattern = {
|
|||
// },
|
||||
...boldItalicMarkup,
|
||||
{
|
||||
name: "markup.underline.link.typst",
|
||||
match: /https?:\/\/[0-9a-zA-Z~\/%#&='',;\.\+\?\-\_]*/,
|
||||
include: "#markupLink",
|
||||
},
|
||||
{
|
||||
include: "#markupMath",
|
||||
|
|
@ -704,6 +703,42 @@ const expressions = (): textmate.Grammar => {
|
|||
};
|
||||
};
|
||||
|
||||
const link = (): textmate.Grammar => {
|
||||
const markupLink: textmate.Pattern = {
|
||||
name: "markup.underline.link.typst",
|
||||
begin: /(?:https?):\/\//,
|
||||
end: /(?=[\s\]\)]|(?=[!,.:;?'](?:[\s\]\)]|$)))/,
|
||||
patterns: [
|
||||
{ include: "#markupLinkParen" },
|
||||
{ include: "#markupLinkBracket" },
|
||||
{
|
||||
match:
|
||||
/(^|\G)(?:[0-9a-zA-Z#$%&*\+\-\/\=\@\_\~]+|(?:[!,.:;?']+(?![\s\]\)]|$)))/,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const markupLinkParen: textmate.Pattern = {
|
||||
begin: /\(/,
|
||||
end: /\)|(?=[\s\]])/,
|
||||
patterns: [{ include: "#markupLink" }],
|
||||
};
|
||||
|
||||
const markupLinkBracket: textmate.Pattern = {
|
||||
begin: /\[/,
|
||||
end: /\]|(?=[\s\)])/,
|
||||
patterns: [{ include: "#markupLink" }],
|
||||
};
|
||||
|
||||
return {
|
||||
repository: {
|
||||
markupLink,
|
||||
markupLinkParen,
|
||||
markupLinkBracket,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
const blockComment: textmate.Pattern = {
|
||||
name: "comment.block.typst",
|
||||
begin: /\/\*/,
|
||||
|
|
@ -1460,6 +1495,7 @@ export const typst: textmate.Grammar = {
|
|||
markupBold,
|
||||
markupItalic,
|
||||
markupMath,
|
||||
...link().repository,
|
||||
markupHeading,
|
||||
markupBrace,
|
||||
mathBrace,
|
||||
|
|
|
|||
|
|
@ -1,2 +1,4 @@
|
|||
>https://zh.wikipedia.org
|
||||
#^^^^^^^^^^^^^^^^^^^^^^^^ source.typst markup.underline.link.typst
|
||||
#^^^^^^^^ source.typst markup.underline.link.typst
|
||||
# ^^ source.typst markup.underline.link.typst
|
||||
# ^^^^^^^^^^^^^^ source.typst markup.underline.link.typst
|
||||
|
|
@ -35,7 +35,9 @@
|
|||
# ^^^ source.typst meta.expr.call.typst markup.raw.block.typst punctuation.definition.raw.begin.typst
|
||||
# ^^^ source.typst meta.expr.call.typst markup.raw.block.typst fenced_code.block.language.typst
|
||||
# ^ source.typst meta.expr.call.typst markup.raw.block.typst meta.embedded.block.typst
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^ source.typst meta.expr.call.typst markup.raw.block.typst meta.embedded.block.typst markup.underline.link.typst
|
||||
# ^^^^^^^^ source.typst meta.expr.call.typst markup.raw.block.typst meta.embedded.block.typst markup.underline.link.typst
|
||||
# ^^ source.typst meta.expr.call.typst markup.raw.block.typst meta.embedded.block.typst markup.underline.link.typst
|
||||
# ^^^^^^^^^^^^^^ source.typst meta.expr.call.typst markup.raw.block.typst meta.embedded.block.typst markup.underline.link.typst
|
||||
# ^^^ source.typst meta.expr.call.typst markup.raw.block.typst punctuation.definition.raw.end.typst
|
||||
# ^ source.typst meta.expr.call.typst meta.brace.round.typst
|
||||
>
|
||||
|
|
@ -43,7 +45,9 @@
|
|||
#^^^^ source.typst markup.raw.block.typst punctuation.definition.raw.begin.typst
|
||||
# ^^^ source.typst markup.raw.block.typst fenced_code.block.language.typst
|
||||
>https://zh.wikipedia.org
|
||||
#^^^^^^^^^^^^^^^^^^^^^^^^ source.typst markup.raw.block.typst meta.embedded.block.typst markup.underline.link.typst
|
||||
#^^^^^^^^ source.typst markup.raw.block.typst meta.embedded.block.typst markup.underline.link.typst
|
||||
# ^^ source.typst markup.raw.block.typst meta.embedded.block.typst markup.underline.link.typst
|
||||
# ^^^^^^^^^^^^^^ source.typst markup.raw.block.typst meta.embedded.block.typst markup.underline.link.typst
|
||||
>````
|
||||
#^^^^ source.typst markup.raw.block.typst punctuation.definition.raw.end.typst
|
||||
>
|
||||
|
|
|
|||
2
syntaxes/textmate/tests/unit/basic/url.typ
Normal file
2
syntaxes/textmate/tests/unit/basic/url.typ
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
https://[::1]:8080/test
|
||||
https://test.
|
||||
11
syntaxes/textmate/tests/unit/basic/url.typ.snap
Normal file
11
syntaxes/textmate/tests/unit/basic/url.typ.snap
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
>https://[::1]:8080/test
|
||||
#^^^^^^^^ source.typst markup.underline.link.typst
|
||||
# ^ source.typst markup.underline.link.typst
|
||||
# ^^^ source.typst markup.underline.link.typst
|
||||
# ^ source.typst markup.underline.link.typst
|
||||
# ^^^^^^^^^^ source.typst markup.underline.link.typst
|
||||
>https://test.
|
||||
#^^^^^^^^ source.typst markup.underline.link.typst
|
||||
# ^^^^ source.typst markup.underline.link.typst
|
||||
# ^^ source.typst
|
||||
>
|
||||
|
|
@ -1,8 +1,9 @@
|
|||
>("https://github.com/Myriad-Dreamin/tinymist/tree/main/editors/vscode#symbol-view")[integrating]
|
||||
#^ source.typst markup.content.brace.typst
|
||||
# ^ source.typst
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.typst markup.underline.link.typst
|
||||
# ^ source.typst
|
||||
# ^^^^^^^^ source.typst markup.underline.link.typst
|
||||
# ^^^^^^ source.typst markup.underline.link.typst
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.typst markup.underline.link.typst
|
||||
# ^ source.typst markup.content.brace.typst
|
||||
# ^ source.typst markup.content.brace.typst
|
||||
# ^^^^^^^^^^^ source.typst
|
||||
|
|
@ -10,8 +11,9 @@
|
|||
>("https://github.com/istudyatuni/sublimelsp-LSP/blob/40ea8ea01af19b8719b0e2e827dbfb8651261199/docs/src/language_servers.md#tinymist")[]
|
||||
#^ source.typst markup.content.brace.typst
|
||||
# ^ source.typst
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.typst markup.underline.link.typst
|
||||
# ^ source.typst
|
||||
# ^^^^^^^^ source.typst markup.underline.link.typst
|
||||
# ^^^^^^ source.typst markup.underline.link.typst
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.typst markup.underline.link.typst
|
||||
# ^ source.typst markup.content.brace.typst
|
||||
# ^ source.typst markup.content.brace.typst
|
||||
# ^ source.typst markup.content.brace.typst
|
||||
Loading…
Add table
Add a link
Reference in a new issue