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

Add support for .properties files #980

Merged
merged 1 commit into from
Jun 26, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add support for .properties files
Golmote committed Jun 18, 2016

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 2607dcd9aeb043590f913236748ca3929c1827ad
4 changes: 4 additions & 0 deletions components.js
Original file line number Diff line number Diff line change
@@ -401,6 +401,10 @@ var components = {
"title": "Prolog",
"owner": "Golmote"
},
"properties": {
"title": ".properties",
"owner": "Golmote"
},
"protobuf": {
"title": "Protocol Buffers",
"require": "clike",
9 changes: 9 additions & 0 deletions components/prism-properties.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Prism.languages.properties = {
'comment': /^[ \t]*[#!].*$/m,
'attr-value': {
pattern: /(^[ \t]*(?:\\(?:\r\n|[\s\S])|[^\\\s:=])+?(?: *[=:] *| ))(?:\\(?:\r\n|[\s\S])|.)+/m,
lookbehind: true
},
'attr-name': /^[ \t]*(?:\\(?:\r\n|[\s\S])|[^\\\s:=])+?(?= *[ =:]| )/m,
'punctuation': /[=:]/
};
1 change: 1 addition & 0 deletions components/prism-properties.min.js

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

12 changes: 12 additions & 0 deletions examples/prism-properties.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<h1>.properties</h1>
<p>To use this language, use the class "language-properties".</p>

<h2>Comments</h2>
<pre><code># This is a comment
! This is a comment too</code></pre>

<h2>Properties</h2>
<pre><code>some_key some_value
some\ key\ with\ spaces : some value
some_key = some \
multiline value</code></pre>
2 changes: 1 addition & 1 deletion plugins/show-language/prism-show-language.js
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ if (typeof self === 'undefined' || !self.Prism || !self.document) {
}

// The languages map is built automatically with gulp
var Languages = /*languages_placeholder[*/{"html":"HTML","xml":"XML","svg":"SVG","mathml":"MathML","css":"CSS","clike":"C-like","javascript":"JavaScript","abap":"ABAP","actionscript":"ActionScript","apacheconf":"Apache Configuration","apl":"APL","applescript":"AppleScript","asciidoc":"AsciiDoc","aspnet":"ASP.NET (C#)","autoit":"AutoIt","autohotkey":"AutoHotkey","basic":"BASIC","csharp":"C#","cpp":"C++","coffeescript":"CoffeeScript","css-extras":"CSS Extras","fsharp":"F#","glsl":"GLSL","graphql":"GraphQL","http":"HTTP","inform7":"Inform 7","json":"JSON","latex":"LaTeX","lolcode":"LOLCODE","matlab":"MATLAB","mel":"MEL","nasm":"NASM","nginx":"nginx","nsis":"NSIS","objectivec":"Objective-C","ocaml":"OCaml","parigp":"PARI/GP","php":"PHP","php-extras":"PHP Extras","powershell":"PowerShell","protobuf":"Protocol Buffers","jsx":"React JSX","rest":"reST (reStructuredText)","sas":"SAS","sass":"Sass (Sass)","scss":"Sass (Scss)","sql":"SQL","typescript":"TypeScript","vhdl":"VHDL","vim":"vim","wiki":"Wiki markup","yaml":"YAML"}/*]*/;
var Languages = /*languages_placeholder[*/{"html":"HTML","xml":"XML","svg":"SVG","mathml":"MathML","css":"CSS","clike":"C-like","javascript":"JavaScript","abap":"ABAP","actionscript":"ActionScript","apacheconf":"Apache Configuration","apl":"APL","applescript":"AppleScript","asciidoc":"AsciiDoc","aspnet":"ASP.NET (C#)","autoit":"AutoIt","autohotkey":"AutoHotkey","basic":"BASIC","csharp":"C#","cpp":"C++","coffeescript":"CoffeeScript","css-extras":"CSS Extras","fsharp":"F#","glsl":"GLSL","graphql":"GraphQL","http":"HTTP","inform7":"Inform 7","json":"JSON","latex":"LaTeX","lolcode":"LOLCODE","matlab":"MATLAB","mel":"MEL","nasm":"NASM","nginx":"nginx","nsis":"NSIS","objectivec":"Objective-C","ocaml":"OCaml","parigp":"PARI/GP","php":"PHP","php-extras":"PHP Extras","powershell":"PowerShell","properties":".properties","protobuf":"Protocol Buffers","jsx":"React JSX","rest":"reST (reStructuredText)","sas":"SAS","sass":"Sass (Sass)","scss":"Sass (Scss)","sql":"SQL","typescript":"TypeScript","vhdl":"VHDL","vim":"vim","wiki":"Wiki markup","yaml":"YAML"}/*]*/;
Prism.hooks.add('before-highlight', function(env) {
var pre = env.element.parentNode;
if (!pre || !/pre/i.test(pre.nodeName)) {
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.

17 changes: 17 additions & 0 deletions tests/languages/properties/comment_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
!
# Foobar baz
! Foobar baz

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

[
["comment", "#"],
["comment", "!"],
["comment", "# Foobar baz"],
["comment", "! Foobar baz"]
]

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

Checks for comments.
36 changes: 36 additions & 0 deletions tests/languages/properties/key_value_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
foo bar
foo\:\=\ bar bar\:\= \
baz
foo = bar
foo\:\=\ bar = bar\:\= \
baz
foo : bar
foo\:\=\ bar : bar\:\= \
baz

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

[
["attr-name", "foo"],
["attr-value", "bar"],
["attr-name", "foo\\:\\=\\ bar"],
["attr-value", "bar\\:\\= \\\r\nbaz"],

["attr-name", "foo"],
["punctuation", "="],
["attr-value", "bar"],
["attr-name", "foo\\:\\=\\ bar"],
["punctuation", "="],
["attr-value", "bar\\:\\= \\\r\nbaz"],

["attr-name", "foo"],
["punctuation", ":"],
["attr-value", "bar"],
["attr-name", "foo\\:\\=\\ bar"],
["punctuation", ":"],
["attr-value", "bar\\:\\= \\\r\nbaz"]
]

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

Checks for keys and values.