Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for .gitignore #2481

Merged
merged 7 commits into from Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions components.json
Expand Up @@ -483,6 +483,14 @@
"title": "Icon",
"owner": "Golmote"
},
"ignore": {
"title": ".ignore",
"owner": "osipxd",
"alias": "gitignore",
"aliasTitles": {
"gitignore": ".gitignore"
}
},
"inform7": {
"title": "Inform 7",
"owner": "Golmote"
Expand Down
34 changes: 34 additions & 0 deletions components/prism-ignore.js
@@ -0,0 +1,34 @@
(function (Prism) {
Prism.languages.ignore = {
// https://git-scm.com/docs/gitignore
'header': {
pattern: /(^|[^\\])###.*/,
RunDevelopment marked this conversation as resolved.
Show resolved Hide resolved
lookbehind: true,
alias: ['comment', 'bold']
},
'section': {
pattern: /(^|[^\\])##.*/,
lookbehind: true,
alias: 'comment'
RunDevelopment marked this conversation as resolved.
Show resolved Hide resolved
},
'comment': {
pattern: /(^|[^\\])#.*/,
lookbehind: true,
alias: 'namespace'
RunDevelopment marked this conversation as resolved.
Show resolved Hide resolved
},
'entry': {
pattern: /\S(?:.*(?:(?:\\ )|\S))?/,
alias: 'string',
inside: {
'regex': {
pattern: /^!|(^|[^\\])[\[\]]/,
lookbehind: true
},
RunDevelopment marked this conversation as resolved.
Show resolved Hide resolved
'punctuation': /\//
}
}
};

Prism.languages.gitignore = Prism.languages.ignore

}(Prism));
1 change: 1 addition & 0 deletions components/prism-ignore.min.js

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

9 changes: 9 additions & 0 deletions examples/prism-ignore.html
@@ -0,0 +1,9 @@
<h2>Comment</h2>
<pre><code># Simple comment
## Section
### Header</code></pre>

<h2>Entry</h2>
<pre><code>file[1-3].txt
.configs/**
!.configs/shared.cfg</code></pre>
1 change: 1 addition & 0 deletions plugins/autoloader/prism-autoloader.js
Expand Up @@ -172,6 +172,7 @@
"xls": "excel-formula",
"gamemakerlanguage": "gml",
"hs": "haskell",
"gitignore": "ignore",
"webmanifest": "json",
"kt": "kotlin",
"kts": "kotlin",
Expand Down
2 changes: 1 addition & 1 deletion plugins/autoloader/prism-autoloader.min.js

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

2 changes: 2 additions & 0 deletions plugins/show-language/prism-show-language.js
Expand Up @@ -81,6 +81,8 @@
"hpkp": "HTTP Public-Key-Pins",
"hsts": "HTTP Strict-Transport-Security",
"ichigojam": "IchigoJam",
"ignore": ".ignore",
"gitignore": ".gitignore",
"inform7": "Inform 7",
"javadoc": "JavaDoc",
"javadoclike": "JavaDoc-like",
Expand Down
2 changes: 1 addition & 1 deletion plugins/show-language/prism-show-language.min.js

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

19 changes: 19 additions & 0 deletions tests/languages/ignore/comment_feature.test
@@ -0,0 +1,19 @@
# Simple comment
## Section comment
### Header comment
\# Not a comment
\## Not a section

----------------------------------------------------

[
["comment", "# Simple comment"],
["section", "## Section comment"],
["header", "### Header comment"],
["entry", ["\\# Not a comment"]],
["entry", ["\\#"]], ["comment", "# Not a section"]
]

----------------------------------------------------

Checks for comments.