Skip to content

Commit

Permalink
1.4.1
Browse files Browse the repository at this point in the history
- Fix newlines breaking highlighting (fix #1)
- Fix superfluous spaces being added (fix #2)
  • Loading branch information
Nixinova committed May 29, 2021
1 parent de7710e commit 9726d35
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 50 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = crlf
insert_final_newline = true
trim_trailing_whitespace = true
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# General
* text=auto

# Project
package-lock.json -diff
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ test/

*.local.*
*.js
*.yaml
*.d.ts
*.json
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 1.4.1
- Fixed newlines breaking attribute syntax highlighting (#1).
- Fixed selectors not having syntax highlighting applied when not at the start of a line.
- Fixed empty parameters having superfluous spaces added when formatted (#2).
- Fixed pseudo-classes after parenthetical selectors having invalid spaces added (#2).

## 1.4.0
- Added breakpoint snippet.
- Added previous element selector syntax highlighting.
Expand Down
3 changes: 2 additions & 1 deletion formatters/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export function activate(context: vscode.ExtensionContext) {
.replace(/(?<=(?:\$\(|\))[^()]+) *\)/g, ' )')
.replace(/\$\(\s+([^$()|]+)\s+\)/g, '$($1)')
.replace(/ *\| */g, ' | ')
.replace(/ \|/g, ' |')
.replace(/(?<=\|)(.*?) *=\s*/g, '$1 = ')
.replace(/^ ([|)])/gm, '$1')

Expand All @@ -23,7 +24,7 @@ export function activate(context: vscode.ExtensionContext) {

// CSS
.replace(/ *{/g, ' {')
.replace(/(?<=[{(][^}]*)([a-z-]+)\s*:(?!\/\/) */g, '$1: ')
.replace(/(?<=[{(][^})]*)([a-z-]+)\s*:(?!\/\/) +/g, '$1: ')
.replace(/; *(?!})/g, '; ')
.replace(/\s*;/g, ';')
.replace(/!\s*important/g, '!important')
Expand Down
40 changes: 21 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Syntax highlighter and formatter for NovaSheets files",
"publisher": "Nixinova",
"repository": "NovaSheets-vscode",
"version": "1.4.0",
"version": "1.4.1",
"license": "ISC",
"scripts": {
"vscode:prepublish": "npm run compile",
Expand Down Expand Up @@ -54,7 +54,7 @@
},
"devDependencies": {
"@types/vscode": "^1.54.0",
"typescript": "^4.2.3",
"typescript": "~4.3.2",
"yamljs": "^0.3.0"
}
}
33 changes: 7 additions & 26 deletions syntaxes/novasheets.tmLanguage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ repository:
css:
patterns:
- include: '#selectors'
- include: '#attributes'
- include: '#at-rules'
- include: '#functions'
- include: '#block'

declarations:
patterns:
Expand All @@ -48,7 +48,7 @@ repository:

# Parser constant
- name: meta.preprocessor.novasheets
match: '(@option)\s+([A-Z_]+)\s+(?=\d+|true|false)'
match: '(@option)\s+([A-Z_]+)\s+'
captures:
1: { name: keyword.control.declaration.option.novasheets }
2: { name: variable.parameter.option.novasheets }
Expand Down Expand Up @@ -163,12 +163,12 @@ repository:
selectors:
patterns:
- name: meta.selector.novasheets
begin: '(?<!@[^$@{}])^(?=\s*[A-Za-z&%,.#:+~>\[\]])(?![^}]*$)'
begin: '(?<!@[^$@{}])(?=\s*[A-Za-z&%,.#:+~>\[\]])(?=.*{)'
end: '(?=\{)'
patterns:
# Element
- name: entity.name.tag.css.selector.element.css
match: '(?<=\s|^|,)[A-Za-z]+[0-9]?(?=\s|[\[,.#:+~>])'
match: '\w+(?=[\s{\[,.#:+~>])'
# Class
- name: entity.name.tag.css.selector.class.css
match: '(\.)(?>\\\s|[^\s,.#:+~>\[\]])+'
Expand Down Expand Up @@ -222,31 +222,12 @@ repository:
- include: '#novasheets'
- include: '#chars'

block:
name: meta.block.css
begin: '{'
beginCaptures:
0: { name: punctuation.definition.block.begin.css }
end: '}'
endCaptures:
0: { name: punctuation.definition.block.end.css }
attributes:
patterns:
# Attribute
- name: meta.language.attribute.name.css
match: '(?<=[;{])\s*([\w-]+)\s*(:)'
- name: entity.other.attribute-name.css
match: '([\w-]+)(:)'
captures:
1: { name: entity.other.attribute-name.css }
2: { name: punctuation.terminator.attribute.name.end.css }
# Value
- name: meta.language.attribute.value.css
begin: '(?<=[{:;])'
end: ';|(?=})'
endCaptures:
0: { name: punctuation.terminator.attribute.value.end.css }
patterns:
- include: '#novasheets'
- include: '#functions'
- include: '#chars'

at-rules:
patterns:
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/* Basic Options */
//"incremental": true,
"target": "es2017",
"target": "es2018",
"module": "commonjs",
//"lib": [],
//"allowJs": true,
Expand Down

0 comments on commit 9726d35

Please sign in to comment.