Skip to content

Commit

Permalink
Adjustments for ST4131+
Browse files Browse the repository at this point in the history
This commit ...

1. adjusts Ruby on Rails base syntax/scopes as they changed
   as of ST 4131

2. adds Markdown support.
   Rewritten Markdown is shipped with ST 4134+.
   
   Hence ST4131 will fail loading and highlighting Markdown, but as it
   is the only public available dev build, which does so, it is used as
   breaking point for the new branch anyway. It's unlikely enough to be
   actively used. If so, update to next build solves the issue.

   Hence CI tests use ST4134 as oldest build to test against.

Notes:

ST 4130, 4132, 4133 don't exist as has been fixed up by next higher
builds. No syntax_test runners exist for fixed-up builds.
  • Loading branch information
deathaxe committed Dec 30, 2022
1 parent 486667e commit 3eed86a
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 46 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci-syntax-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ jobs:
strategy:
matrix:
include:
- build: 4107
default_packages: v4107
- build: 4129
default_packages: v4129
- build: 4134
default_packages: v4134
- build: latest
default_packages: master
steps:
- name: Checkout Default Packages
uses: actions/checkout@v3
Expand Down
35 changes: 0 additions & 35 deletions Syntaxes/Embeddings/HTML (for Slim).sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,6 @@ hidden: true

extends: Packages/HTML/HTML.sublime-syntax

variables:

# Embedded script and style syntaxes may be wrapped into html comments for
# historical reasons. The following patterns match them, while maintaining
# correct boundaries of embedded source scopes. That's required to enable
# embedded syntax's comment toggling in the first and last line.
#
# see:
# - https://github.com/sublimehq/Packages/issues/2322
# - https://github.com/sublimehq/sublime_text/issues/4701
script_content_begin: |-
(?x:
# whitespace followed by opening html comment begin punctuation
\s*(<!--)
# or any other non-whitespace character ahead
| (?=\s*(?!<!--)\S)
# or beginning of a line
| ^
)
script_content_end: |-
(?x:
# optional html comment end punctuation followed by </script> tag
(?: (\s*) (-->) \s* )? (?=</(?i:script){{tag_name_break_char}})
# or standalone html comment end punctuation in a line
| ^ (\s*) (-->) \s* $
)
style_content_begin: '{{script_content_begin}}'
style_content_end: |-
(?x:
# optional html comment end punctuation followed by </style> tag
(?: (\s*) (-->) \s* )? (?=</(?i:style){{tag_name_break_char}})
# or standalone html comment end punctuation in a line
| ^ (\s*) (-->) \s* $
)
contexts:
prototype:
- meta_prepend: true
Expand Down
20 changes: 20 additions & 0 deletions Syntaxes/Embeddings/Markdown (for Slim).sublime-syntax
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
%YAML 1.2
---
# http://www.sublimetext.com/docs/syntax.html
name: Markdown (for Slim)
scope: text.html.markdown.embedded.slim
version: 2
hidden: true

extends: Packages/Markdown/Markdown.sublime-syntax

contexts:
prototype:
- meta_prepend: true
- include: Slim.sublime-syntax#slim-interpolations

main:
- include: indented-markdown

html-content:
- include: scope:text.html.embedded.slim
2 changes: 1 addition & 1 deletion Syntaxes/Embeddings/Ruby (for Slim).sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ scope: source.ruby.rails.embedded.slim
#version: 2
hidden: true

extends: Packages/Rails/Ruby on Rails.sublime-syntax
extends: Packages/Rails/Ruby (Rails).sublime-syntax

contexts:

Expand Down
20 changes: 16 additions & 4 deletions Syntaxes/Slim.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ contexts:
- include: slim-filters-erb
- include: slim-filters-javascript
- include: slim-filters-less
- include: slim-filters-markdown
- include: slim-filters-ruby
- include: slim-filters-sass
- include: slim-filters-scss
Expand Down Expand Up @@ -177,7 +178,7 @@ contexts:
2: meta.filter.slim
3: constant.other.language-name.slim
4: punctuation.definition.filter.slim
embed: scope:text.html.ruby
embed: scope:text.html.rails
embed_scope: meta.filter.slim text.html.erb.embedded.slim
escape: '{{filter_escapes}}'

Expand Down Expand Up @@ -231,6 +232,17 @@ contexts:
embed_scope: source.less.embedded.slim
escape: ^(?=\S)

slim-filters-markdown:
# Compile markdown code and interpolate #variables in text
- match: ^(\s*)((markdown)(:)\s*(\n|$))
captures:
2: meta.filter.slim
3: constant.other.language-name.slim
4: punctuation.definition.filter.slim
embed: scope:text.html.markdown.embedded.slim
embed_scope: meta.filter.slim text.html.markdown.embedded.slim
escape: '{{filter_escapes}}'

slim-filters-plain:
- match: ^(\s*)(({{tag_name}})(:)\s*(\n|$))
captures:
Expand Down Expand Up @@ -661,7 +673,7 @@ contexts:

slim-interpolation-variable:
- meta_scope: meta.interpolation.slim
- include: scope:source.ruby#interpolated-ruby-variables
- include: scope:source.ruby.rails.embedded.slim#interpolated-ruby-variables
apply_prototype: true

ruby-expression:
Expand All @@ -670,9 +682,9 @@ contexts:
- include: immediately-pop

ruby-expressions:
- include: scope:source.ruby#nest-all
- include: scope:source.ruby.rails.embedded.slim#nest-all
apply_prototype: true
- include: scope:source.ruby#expressions
- include: scope:source.ruby.rails.embedded.slim#expressions
apply_prototype: true

###[ CONTINUATIONS ]###########################################################
Expand Down
24 changes: 22 additions & 2 deletions tests/syntax_test_slim.slim
Original file line number Diff line number Diff line change
Expand Up @@ -1532,8 +1532,28 @@ less:
markdown:
# Hello
**World** #{:var}
/ <- meta.filter.slim text.plain - meta.tag
/^^^^^^^^^^^ meta.filter.slim text.plain
/ <- meta.filter.slim text.html.markdown.embedded.slim - meta.tag
/^^^^^^^^^^^ meta.filter.slim text.html.markdown.embedded.slim
/^^^^^^^^ markup.bold.markdown
/ ^^^^^^^ meta.filter.slim text.html.markdown.embedded.slim meta.interpolation.slim
/ ^^ punctuation.section.interpolation.begin.slim
/ ^^^^ source.ruby.rails.embedded.slim constant.other.symbol.ruby
/ ^ punctuation.section.interpolation.end.slim

<br class="#{:name}">
/ <- meta.filter.slim text.html.markdown.embedded.slim meta.tag
/^^^^^^^^^^^^^^^^^^^^ meta.filter.slim text.html.markdown.embedded.slim meta.tag
/ ^^^^^^^^^^^^^^^^ meta.attribute-with-value.class.html
/ ^^^^^^^^ meta.class-name.html meta.string.html meta.interpolation.slim
/^^ entity.name.tag
/ ^^^^^ entity.other.attribute-name.class.html
/ ^ punctuation.separator.key-value.html
/ ^ punctuation.definition.string.begin.html
/ ^^ punctuation.section.interpolation.begin.slim
/ ^^^^^ source.ruby.rails.embedded.slim constant.other.symbol.ruby
/ ^ punctuation.section.interpolation.end.slim
/ ^ punctuation.definition.string.end.html
/ ^ punctuation.definition.tag.end.html

plain:
Plain <b>text</b>
Expand Down

0 comments on commit 3eed86a

Please sign in to comment.