Skip to content

Commit 93a5678

Browse files
committed
Syntax: Add support for pandoc attributes in link defs
Fixes #712
1 parent 855274f commit 93a5678

2 files changed

Lines changed: 58 additions & 3 deletions

File tree

syntaxes/Markdown.sublime-syntax

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2431,25 +2431,44 @@ contexts:
24312431
3: punctuation.definition.reference.end.markdown
24322432
4: punctuation.separator.key-value.markdown
24332433
push:
2434-
- link-def-end
2434+
- link-def-meta
2435+
- link-def-attr
24352436
- link-def-title
24362437
- link-def-url
24372438

2438-
link-def-end:
2439+
link-def-meta:
24392440
- meta_include_prototype: false
24402441
- meta_scope: meta.link.reference.def.markdown
24412442
- include: immediately-pop
24422443

2444+
link-def-attr:
2445+
- match: \{
2446+
scope: punctuation.definition.attributes.begin.markdown
2447+
set: link-def-attr-body
2448+
- match: ^(?!\s*{)|(?=\S)
2449+
pop: 1
2450+
2451+
link-def-attr-body:
2452+
- meta_scope: meta.attributes.markdown
2453+
- include: tag-attributes
2454+
24432455
link-def-title:
24442456
- match: ^(?!\s*["'(])
24452457
pop: true
24462458
- match: (?=["'(])
24472459
set:
2448-
- expect-eol
2460+
- expect-attr-or-eol
24492461
- link-title
2462+
- match: (?=\{)
2463+
pop: 1
24502464
- match: \S.+
24512465
scope: invalid.illegal.expected-eol.markdown
24522466

2467+
expect-attr-or-eol:
2468+
- match: (?=\{)
2469+
pop: 1
2470+
- include: expect-eol
2471+
24532472
link-def-url:
24542473
- match: <
24552474
scope: punctuation.definition.link.begin.markdown
@@ -3206,6 +3225,7 @@ contexts:
32063225
scope: invalid.illegal.attribute-name.markdown
32073226

32083227
tag-attr-meta:
3228+
- meta_include_prototype: false
32093229
- meta_scope: meta.attribute-with-value.markdown
32103230
- include: immediately-pop
32113231

tests/syntax_test_markdown.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2508,6 +2508,41 @@ Foo
25082508
| ^ punctuation.separator.key-value.markdown
25092509
| ^^^^ markup.underline.link.markdown
25102510

2511+
## https://custom-tests/link-reference-definitions/with-attributes
2512+
2513+
[link]: /url {#id .class width=30}
2514+
| ^^^^^^^^^^^^^^^^^^^^^ meta.link.reference.def.markdown meta.attributes.markdown
2515+
2516+
[link]: /url (description) {#id .class width=30}
2517+
| ^^^^^^^^^^^^^^^^^^^^^ meta.link.reference.def.markdown meta.attributes.markdown
2518+
2519+
[link]: /url "description" {#id .class width=30}
2520+
| ^^^^^^^^^^^^^^^^^^^^^ meta.link.reference.def.markdown meta.attributes.markdown
2521+
2522+
[link]:
2523+
/url
2524+
{#id .class width=30}
2525+
| ^^^^^^^^^^^^^^^^^^^^^ meta.link.reference.def.markdown meta.attributes.markdown
2526+
2527+
[link]:
2528+
/url
2529+
2530+
{#id .class width=30}
2531+
| ^^^^^^^^^^^^^^^^^^^^^ - meta.link - meta.attributes
2532+
2533+
[link]:
2534+
/url
2535+
"description"
2536+
{#id .class width=30}
2537+
| ^^^^^^^^^^^^^^^^^^^^^ meta.link.reference.def.markdown meta.attributes.markdown
2538+
2539+
[link]:
2540+
/url
2541+
"description"
2542+
2543+
{#id .class width=30}
2544+
| ^^^^^^^^^^^^^^^^^^^^^ - meta.link - meta.attributes
2545+
25112546
## https://custom-tests/link-reference-definitions/in-block-quotes
25122547

25132548
> [foo]: /url "description"

0 commit comments

Comments
 (0)