-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug #179 🐛 Fix yaml number rendering (homersimpsons)
This PR was squashed before being merged into the main branch. Discussion ---------- :bug: Fix yaml number rendering Fixes #177 I copied the yaml.json file from https://github.com/scrivo/highlight.php/blob/d1c6b0956a2b0d3efc137e4d8c5bf5c5e220bac1/src/Highlight/languages/yaml.json#L84 and updated the "number" regex to add `_` where I think the symfony parser allow them: ```diff - "begin": "(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)\\b" + "begin": "(-?)(\\b0[xX][a-fA-F0-9_]+|(\\b\\d[\\d_]*(\\.[\\d_]*)?|\\.\\d[\\d_]*)([eE][-+]?\\d[\\d_]*)?)\\b" ``` There may be additional places where the symfony parser allow the `_` for numbers. I also updated the tests to add the example from the documentation. Commits ------- e7c0a06 🐛 Fix yaml number rendering
- Loading branch information
Showing
4 changed files
with
170 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
{ | ||
"case_insensitive": true, | ||
"aliases": [ | ||
"yml", | ||
"YAML", | ||
"yaml" | ||
], | ||
"contains": [ | ||
{ | ||
"className": "attr", | ||
"variants": [ | ||
{ | ||
"begin": "\\w[\\w :\\\/.-]*:(?=[ \t]|$)" | ||
}, | ||
{ | ||
"begin": "\"\\w[\\w :\\\/.-]*\":(?=[ \t]|$)" | ||
}, | ||
{ | ||
"begin": "'\\w[\\w :\\\/.-]*':(?=[ \t]|$)" | ||
} | ||
] | ||
}, | ||
{ | ||
"className": "meta", | ||
"begin": "^---s*$", | ||
"relevance": 10 | ||
}, | ||
{ | ||
"className": "string", | ||
"begin": "[\\|>]([0-9]?[+-])?[ ]*\\n( *)[\\S ]+\\n(\\2[\\S ]+\\n?)*" | ||
}, | ||
{ | ||
"begin": "<%[%=-]?", | ||
"end": "[%-]?%>", | ||
"subLanguage": "ruby", | ||
"excludeBegin": true, | ||
"excludeEnd": true, | ||
"relevance": 0 | ||
}, | ||
{ | ||
"className": "type", | ||
"begin": "![a-zA-Z_]\\w*" | ||
}, | ||
{ | ||
"className": "type", | ||
"begin": "!![a-zA-Z_]\\w*" | ||
}, | ||
{ | ||
"className": "meta", | ||
"begin": "&[a-zA-Z_]\\w*$" | ||
}, | ||
{ | ||
"className": "meta", | ||
"begin": "\\*[a-zA-Z_]\\w*$" | ||
}, | ||
{ | ||
"className": "bullet", | ||
"begin": "\\-(?=[ ]|$)", | ||
"relevance": 0 | ||
}, | ||
{ | ||
"className": "comment", | ||
"begin": "#", | ||
"end": "$", | ||
"contains": [ | ||
{ | ||
"begin": "\\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\\b" | ||
}, | ||
{ | ||
"className": "doctag", | ||
"begin": "(?:TODO|FIXME|NOTE|BUG|XXX):", | ||
"relevance": 0 | ||
} | ||
] | ||
}, | ||
{ | ||
"beginKeywords": "true false yes no null", | ||
"keywords": { | ||
"literal": "true false yes no null" | ||
} | ||
}, | ||
{ | ||
"className": "number", | ||
"begin": "\\b([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(([Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(\\.([0-9]*))?([ \\t]*(Z|([-+])([0-9][0-9]?)(:([0-9][0-9]))?))?)?\\b" | ||
}, | ||
{ | ||
"className": "number", | ||
"begin": "(-?)(\\b0[xX][a-fA-F0-9_]+|(\\b\\d[\\d_]*(\\.[\\d_]*)?|\\.\\d[\\d_]*)([eE][-+]?\\d[\\d_]*)?)\\b" | ||
}, | ||
{ | ||
"className": "string", | ||
"relevance": 0, | ||
"variants": [ | ||
{ | ||
"begin": "'", | ||
"end": "'" | ||
}, | ||
{ | ||
"begin": "\"", | ||
"end": "\"" | ||
}, | ||
{ | ||
"begin": "\\S+" | ||
} | ||
], | ||
"contains": [ | ||
{ | ||
"begin": "\\\\[\\s\\S]", | ||
"relevance": 0 | ||
}, | ||
{ | ||
"className": "template-variable", | ||
"variants": [ | ||
{ | ||
"begin": "{{", | ||
"end": "}}" | ||
}, | ||
{ | ||
"begin": "%{", | ||
"end": "}" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,36 @@ | ||
<div translate="no" data-loc="1" class="notranslate codeblock codeblock-length-sm codeblock-yaml"> | ||
<div translate="no" data-loc="10" class="notranslate codeblock codeblock-length-md codeblock-yaml"> | ||
<div class="codeblock-scroll"> | ||
<pre class="codeblock-lines">1</pre> | ||
<pre class="codeblock-code"><code><span class="hljs-comment"># some code</span> | ||
</code></pre> | ||
<pre class="codeblock-lines">1 | ||
2 | ||
3 | ||
4 | ||
5 | ||
6 | ||
7 | ||
8 | ||
9 | ||
10</pre> | ||
<pre class="codeblock-code"> | ||
<code> | ||
<span class="hljs-comment"># some code</span> | ||
<span class="hljs-attr">parameters:</span> | ||
<span class="hljs-attr">credit_card_number:</span> | ||
<span class="hljs-number">1234_5678_9012_3456</span> | ||
<span class="hljs-attr">long_number:</span> | ||
<span class="hljs-number">10_000_000_000</span> | ||
<span class="hljs-attr">pi:</span> | ||
<span class="hljs-number">3.14159_26535_89793</span> | ||
<span class="hljs-attr">hex_words:</span> | ||
<span class="hljs-number">0x_CAFE_F00D</span> | ||
<span class="hljs-attr">canonical:</span> | ||
<span class="hljs-number">2001-12-15T02:59:43.1Z</span> | ||
<span class="hljs-attr">iso8601:</span> | ||
<span class="hljs-number">2001-12-14t21:59:43.10-05:00</span> | ||
<span class="hljs-attr">spaced:</span> | ||
<span class="hljs-number">2001-12-14 21:59:43.10 -5</span> | ||
<span class="hljs-attr">date:</span> | ||
<span class="hljs-number">2002-12-14</span> | ||
</code> | ||
</pre> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
|
||
.. code-block:: yaml | ||
# some code | ||
parameters: | ||
credit_card_number: 1234_5678_9012_3456 | ||
long_number: 10_000_000_000 | ||
pi: 3.14159_26535_89793 | ||
hex_words: 0x_CAFE_F00D | ||
canonical: 2001-12-15T02:59:43.1Z | ||
iso8601: 2001-12-14t21:59:43.10-05:00 | ||
spaced: 2001-12-14 21:59:43.10 -5 | ||
date: 2002-12-14 |