Commit 2141129f4db62cc251a3182edad80a170acb19be

dvdhansen 2019-05-28T23:07:39

Julia: Highlight ‘Inf’ and ‘NaN’ as constants (#1921) This highlight `Inf`, `NaN` and all of their variants as constants.

diff --git a/components/prism-julia.js b/components/prism-julia.js
index 079fe0e..b11b628 100644
--- a/components/prism-julia.js
+++ b/components/prism-julia.js
@@ -8,5 +8,6 @@ Prism.languages.julia= {
 	'boolean' : /\b(?:true|false)\b/,
 	'number' : /(?:\b(?=\d)|\B(?=\.))(?:0[box])?(?:[\da-f]+\.?\d*|\.\d+)(?:[efp][+-]?\d+)?j?/i,
 	'operator': /[-+*^%÷&$\\]=?|\/[\/=]?|!=?=?|\|[=>]?|<(?:<=?|[=:])?|>(?:=|>>?=?)?|==?=?|[~≠≤≥]/,
-	'punctuation' : /[{}[\];(),.:]/
+	'punctuation' : /[{}[\];(),.:]/,
+	'constant': /\b(?:(?:NaN|Inf)(?:16|32|64)?)\b/
 };
diff --git a/components/prism-julia.min.js b/components/prism-julia.min.js
index 95e1f8d..5af9a7b 100644
--- a/components/prism-julia.min.js
+++ b/components/prism-julia.min.js
@@ -1 +1 @@
-Prism.languages.julia={comment:{pattern:/(^|[^\\])#.*/,lookbehind:!0},string:/("""|''')[\s\S]+?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2/,keyword:/\b(?:abstract|baremodule|begin|bitstype|break|catch|ccall|const|continue|do|else|elseif|end|export|finally|for|function|global|if|immutable|import|importall|in|let|local|macro|module|print|println|quote|return|try|type|typealias|using|while)\b/,boolean:/\b(?:true|false)\b/,number:/(?:\b(?=\d)|\B(?=\.))(?:0[box])?(?:[\da-f]+\.?\d*|\.\d+)(?:[efp][+-]?\d+)?j?/i,operator:/[-+*^%÷&$\\]=?|\/[\/=]?|!=?=?|\|[=>]?|<(?:<=?|[=:])?|>(?:=|>>?=?)?|==?=?|[~≠≤≥]/,punctuation:/[{}[\];(),.:]/};
\ No newline at end of file
+Prism.languages.julia={comment:{pattern:/(^|[^\\])#.*/,lookbehind:!0},string:/("""|''')[\s\S]+?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2/,keyword:/\b(?:abstract|baremodule|begin|bitstype|break|catch|ccall|const|continue|do|else|elseif|end|export|finally|for|function|global|if|immutable|import|importall|in|let|local|macro|module|print|println|quote|return|try|type|typealias|using|while)\b/,boolean:/\b(?:true|false)\b/,number:/(?:\b(?=\d)|\B(?=\.))(?:0[box])?(?:[\da-f]+\.?\d*|\.\d+)(?:[efp][+-]?\d+)?j?/i,operator:/[-+*^%÷&$\\]=?|\/[\/=]?|!=?=?|\|[=>]?|<(?:<=?|[=:])?|>(?:=|>>?=?)?|==?=?|[~≠≤≥]/,punctuation:/[{}[\];(),.:]/,constant:/\b(?:(?:NaN|Inf)(?:16|32|64)?)\b/};
\ No newline at end of file
diff --git a/tests/languages/julia/constant_feature.test b/tests/languages/julia/constant_feature.test
new file mode 100644
index 0000000..402418a
--- /dev/null
+++ b/tests/languages/julia/constant_feature.test
@@ -0,0 +1,19 @@
+NaN NaN16 NaN32 NaN64
+Inf Inf16 Inf32 Inf64
+
+----------------------------------------------------
+
+[
+	["constant", "NaN"],
+	["constant", "NaN16"],
+	["constant", "NaN32"],
+	["constant", "NaN64"],
+	["constant", "Inf"],
+	["constant", "Inf16"],
+	["constant", "Inf32"],
+	["constant", "Inf64"]
+]
+
+----------------------------------------------------
+
+Checks for all constants.
\ No newline at end of file