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 all 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.

14 changes: 14 additions & 0 deletions components.json
Expand Up @@ -483,6 +483,20 @@
"title": "Icon",
"owner": "Golmote"
},
"ignore": {
"title": ".ignore",
"owner": "osipxd",
"alias": [
"gitignore",
"hgignore",
"npmignore"
],
"aliasTitles": {
"gitignore": ".gitignore",
"hgignore": ".hgignore",
"npmignore": ".npmignore"
}
},
"inform7": {
"title": "Inform 7",
"owner": "Golmote"
Expand Down
23 changes: 23 additions & 0 deletions components/prism-ignore.js
@@ -0,0 +1,23 @@
(function (Prism) {
Prism.languages.ignore = {
// https://git-scm.com/docs/gitignore
'comment': /^#.*/m,
'entry': {
pattern: /\S(?:.*(?:(?:\\ )|\S))?/,
alias: 'string',
inside: {
'operator': /^!|\*\*?|\?/,
'regex': {
pattern: /(^|[^\\])\[[^\[\]]*\]/,
lookbehind: true
},
'punctuation': /\//
}
}
};

Prism.languages.gitignore = Prism.languages.ignore
Prism.languages.hgignore = Prism.languages.ignore
Prism.languages.npmignore = 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.

7 changes: 7 additions & 0 deletions examples/prism-ignore.html
@@ -0,0 +1,7 @@
<h2>Comment</h2>
<pre><code># This is a comment</code></pre>

<h2>Entry</h2>
<pre><code>file[1-3].txt
.configs/**
!.configs/shared.cfg</code></pre>
3 changes: 3 additions & 0 deletions plugins/autoloader/prism-autoloader.js
Expand Up @@ -172,6 +172,9 @@
"xls": "excel-formula",
"gamemakerlanguage": "gml",
"hs": "haskell",
"gitignore": "ignore",
"hgignore": "ignore",
"npmignore": "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.

4 changes: 4 additions & 0 deletions plugins/show-language/prism-show-language.js
Expand Up @@ -81,6 +81,10 @@
"hpkp": "HTTP Public-Key-Pins",
"hsts": "HTTP Strict-Transport-Security",
"ichigojam": "IchigoJam",
"ignore": ".ignore",
"gitignore": ".gitignore",
"hgignore": ".hgignore",
"npmignore": ".npmignore",
"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.

15 changes: 15 additions & 0 deletions tests/languages/ignore/comment_feature.test
@@ -0,0 +1,15 @@
# Simple comment
## A comment too
\# Not a comment

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

[
["comment", "# Simple comment"],
["comment", "## A comment too"],
["entry", ["\\# Not a comment"]]
]

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

Checks for comments.