Skip to content

Commit

Permalink
Added support for .gitignore (#2481)
Browse files Browse the repository at this point in the history
  • Loading branch information
osipxd committed Jul 22, 2020
1 parent 0c30c58 commit 3fcce6f
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 3 deletions.
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.

0 comments on commit 3fcce6f

Please sign in to comment.