-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
1,037 additions
and
1,486 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
let g:editorconfig = v:false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
html lang="en" { | ||
head { | ||
meta charset="UTF-8" {} | ||
meta | ||
name="viewport" | ||
content="width=device-width, initial-scale=1.0" | ||
{} | ||
link href="/favicon.svg" rel="shortcut icon" type="image/svg" {} | ||
link href="/style.svg" rel="stylesheet" {} | ||
title {-My Website Title} | ||
} | ||
|
||
body { | ||
p #my-id {= This is a paragraph with the id ‘my-id’ } | ||
p .my-cls {= This is a paragraph with the class ‘my-cls’ } | ||
|
||
/ div { | ||
p {- This entire div is commented out. } | ||
p {- Isn’t that neat? } | ||
} | ||
|
||
p | ||
#some-id | ||
.class-1 | ||
.class-2 | ||
key-1="value-1" | ||
key-2 = "value-2" | ||
{- | ||
This paragraph has an ID, two classes, and two additional | ||
attributes. GSP allows us to use the ‘#ident’ and ‘.ident’ | ||
syntaxes as shorthands for applying IDs, and classes. This | ||
is a text node, so nothing is being interpreted as GSP nodes, | ||
but we can include them inline if we want. As an example, | ||
here is some @em {-emphatic} text. Your inline nodes can | ||
also have attributes @em #id {-just like a regular node}. | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,38 @@ | ||
const IDENT = /\p{XID_Start}[-\p{XID_Continue}]*/u | ||
|
||
module.exports = grammar({ | ||
name: 'gsp', | ||
extras: $ => [$._S], | ||
extras: $ => [/\p{Pattern_White_Space}+/u], | ||
rules: { | ||
source_file: $ => repeat(choice($.comment, $.node)), | ||
document: $ => repeat($._toplevel), | ||
_toplevel: $ => choice($.comment, $.node), | ||
|
||
comment: $ => seq( | ||
'/', | ||
optional($.node_name), | ||
optional($.attribute_list), | ||
'{', | ||
optional($.node_body), | ||
'}', | ||
), | ||
comment: $ => seq('/', $.node), | ||
node: $ => seq($.node_name, optional($.attrs), $.node_body), | ||
|
||
node: $ => seq( | ||
optional('>'), | ||
$.node_name, | ||
optional($.attribute_list), | ||
node_name: $ => IDENT, | ||
node_body: $ => seq( | ||
'{', | ||
optional($.node_body), | ||
'}', | ||
), | ||
|
||
node_body: $ => choice( | ||
repeat1(choice($.comment, $.node)), | ||
seq(choice('-', '='), optional($.text)), | ||
), | ||
|
||
node_name: $ => /[a-zA-Z:_\u{000C0}-\u{000D6}\u{000D8}-\u{000F6}\u{000F8}-\u{002FF}\u{00370}-\u{0037D}\u{0037F}-\u{01FFF}\u{0200C}-\u{0200D}\u{02070}-\u{0218F}\u{02C00}-\u{02FEF}\u{03001}-\u{0D7FF}\u{0F900}-\u{0FDCF}\u{0FDF0}-\u{0FFFD}\u{10000}-\u{EFFFF}][a-zA-Z0-9:_\-.·\u{00300}-\u{0036F}\u{0203F}-\u{02040}\u{000C0}-\u{000D6}\u{000D8}-\u{000F6}\u{000F8}-\u{002FF}\u{00370}-\u{0037D}\u{0037F}-\u{01FFF}\u{0200C}-\u{0200D}\u{02070}-\u{0218F}\u{02C00}-\u{02FEF}\u{03001}-\u{0D7FF}\u{0F900}-\u{0FDCF}\u{0FDF0}-\u{0FFFD}\u{10000}-\u{EFFFF}]*/u, | ||
|
||
text: $ => repeat1( | ||
choice( | ||
$.literal_text, | ||
seq('@', choice($.comment, $.node)), | ||
), | ||
), | ||
|
||
literal_text: $ => /(\\[@}\\]|[^@}\\])+/, | ||
|
||
attribute_list: $ => repeat1($.attribute), | ||
|
||
attribute: $ => choice( | ||
$.class_shorthand, | ||
$.id_shorthand, | ||
seq( | ||
$.attribute_name, | ||
optional(seq('=', $.attribute_value)), | ||
repeat($._toplevel), | ||
seq(choice('-', '='), optional($.text)), | ||
), | ||
'}', | ||
), | ||
|
||
class_shorthand: $ => /\.\P{White_Space}+/u, | ||
id_shorthand: $ => /#\P{White_Space}+/u, | ||
attrs: $ => repeat1(choice( | ||
$.attr, | ||
$.id_attr, | ||
$.class_attr, | ||
)), | ||
|
||
attribute_name: $ => /[a-zA-Z0-9_-]+/, | ||
attribute_value: $ => /"(\\.|[^"\\])*"/, | ||
attr: $ => seq(IDENT, '=', /"(\\["\\]|[^"\\])+"/), | ||
id_attr: $ => seq('#', token.immediate(IDENT)), | ||
class_attr: $ => seq('.', token.immediate(IDENT)), | ||
|
||
_S: $ => /\p{White_Space}+/u, | ||
text: $ => repeat1(choice( | ||
/(\\[@}\\]|[^@}\\])+/, | ||
seq('@', $._toplevel), | ||
)), | ||
}, | ||
}) |
Oops, something went wrong.