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

ini/toml: Support comments on the same line. #2039

Merged
merged 2 commits into from
May 29, 2019
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: 2 additions & 0 deletions src/languages/ini.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ function(hljs) {
begin: /=/, endsWithParent: true,
relevance: 0,
contains: [
hljs.COMMENT(';', '$'),
hljs.HASH_COMMENT_MODE,
{
className: 'literal',
begin: /\bon|off|true|false|yes|no\b/
Expand Down
5 changes: 5 additions & 0 deletions test/markup/ini/comments.expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<span class="hljs-comment"># Comment</span>
<span class="hljs-comment">; ini-style comment</span>
<span class="hljs-attr">x</span> = <span class="hljs-string">"abc"</span> <span class="hljs-comment"># Comment on same line</span>
<span class="hljs-attr">y</span> = <span class="hljs-number">123</span> <span class="hljs-comment">; Comment on same line</span>
<span class="hljs-section">[table]</span> <span class="hljs-comment">; Comment on same line</span>
5 changes: 5 additions & 0 deletions test/markup/ini/comments.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Comment
; ini-style comment
x = "abc" # Comment on same line
y = 123 ; Comment on same line
[table] ; Comment on same line
4 changes: 4 additions & 0 deletions test/markup/ini/tables.expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<span class="hljs-section">[table]</span>
<span class="hljs-section">[[array]]</span>
<span class="hljs-section">[dotted.table.name]</span>
<span class="hljs-section">[target.'cfg(unix)']</span>
4 changes: 4 additions & 0 deletions test/markup/ini/tables.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[table]
[[array]]
[dotted.table.name]
[target.'cfg(unix)']
20 changes: 20 additions & 0 deletions test/markup/ini/types.expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<span class="hljs-attr">i</span> = <span class="hljs-number">1_234</span>
<span class="hljs-attr">f</span> = <span class="hljs-number">1.23</span>
<span class="hljs-attr">f</span> = <span class="hljs-number">7</span>e+<span class="hljs-number">12</span>
<span class="hljs-attr">f</span> = <span class="hljs-number">2</span>e3
<span class="hljs-attr">f</span> = -<span class="hljs-number">1.234</span>e-<span class="hljs-number">12</span>
<span class="hljs-attr">basic</span> = <span class="hljs-string">"string"</span>
<span class="hljs-attr">multi_basic</span> = <span class="hljs-string">"""multiple
lines"""</span>
<span class="hljs-attr">literal</span> = <span class="hljs-string">'string'</span>
<span class="hljs-attr">multi_literal</span> = <span class="hljs-string">'''multiple
lines'''</span>
<span class="hljs-attr">b</span> = <span class="hljs-literal">true</span>
<span class="hljs-attr">b</span> = <span class="hljs-literal">false</span>
<span class="hljs-attr">b</span> = <span class="hljs-literal">on</span>
<span class="hljs-attr">b</span> = <span class="hljs-literal">off</span>
<span class="hljs-attr">b</span> = <span class="hljs-literal">yes</span>
<span class="hljs-attr">b</span> = <span class="hljs-literal">no</span>
<span class="hljs-attr">dotted.key</span> = <span class="hljs-number">1</span>
<span class="hljs-attr">array</span> = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>]
<span class="hljs-attr">inline</span> = {name = <span class="hljs-string">"foo"</span>, id = <span class="hljs-number">123</span>}
20 changes: 20 additions & 0 deletions test/markup/ini/types.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
i = 1_234
f = 1.23
f = 7e+12
f = 2e3
f = -1.234e-12
basic = "string"
multi_basic = """multiple
lines"""
literal = 'string'
multi_literal = '''multiple
lines'''
b = true
b = false
b = on
b = off
b = yes
b = no
dotted.key = 1
array = [1, 2, 3]
inline = {name = "foo", id = 123}
2 changes: 2 additions & 0 deletions test/markup/ini/variable.expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<span class="hljs-attr">memory_limit</span> = <span class="hljs-variable">${PHP_MEMORY_LIMIT}</span>
<span class="hljs-attr">key</span> = <span class="hljs-variable">$VAR1</span>
2 changes: 2 additions & 0 deletions test/markup/ini/variable.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
memory_limit = ${PHP_MEMORY_LIMIT}
key = $VAR1