bare-script 3.8.5 → 3.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/include/dataTable.bare +12 -1
- package/lib/runtime.js +3 -2
- package/lib/runtimeAsync.js +2 -2
- package/package.json +1 -1
|
@@ -127,7 +127,7 @@ function dataTableMarkdown(data, model):
|
|
|
127
127
|
value = objectGet(row, field)
|
|
128
128
|
valueType = systemType(value)
|
|
129
129
|
if valueType == 'string':
|
|
130
|
-
valueFormat = value
|
|
130
|
+
valueFormat = stringTrim(value)
|
|
131
131
|
elif valueType == 'number':
|
|
132
132
|
valueFormat = numberToFixed(value, precisionNumber, precisionTrim)
|
|
133
133
|
elif valueType == 'datetime':
|
|
@@ -135,6 +135,12 @@ function dataTableMarkdown(data, model):
|
|
|
135
135
|
else:
|
|
136
136
|
valueFormat = stringNew(value)
|
|
137
137
|
endif
|
|
138
|
+
|
|
139
|
+
# Eliminate value string newlines
|
|
140
|
+
valueFormat = regexReplace(dataTableMarkdownRegexMultipleNewline, valueFormat, '<br><br>')
|
|
141
|
+
valueFormat = regexReplace(dataTableMarkdownRegexSingleNewline, valueFormat, ' ')
|
|
142
|
+
|
|
143
|
+
# Set the field value string
|
|
138
144
|
objectSet(rowFormat, field, valueFormat)
|
|
139
145
|
|
|
140
146
|
# Update the field width
|
|
@@ -190,6 +196,11 @@ function dataTableMarkdown(data, model):
|
|
|
190
196
|
endfunction
|
|
191
197
|
|
|
192
198
|
|
|
199
|
+
# Field value newline replacement regular expressions
|
|
200
|
+
dataTableMarkdownRegexMultipleNewline = regexNew('\r?\n(?:\r?\n)+')
|
|
201
|
+
dataTableMarkdownRegexSingleNewline = regexNew('\r?\n')
|
|
202
|
+
|
|
203
|
+
|
|
193
204
|
# Helper to generate the Markdown field text
|
|
194
205
|
function dataTableMarkdownField(value, width, align, fill):
|
|
195
206
|
spaces = width - stringLength(value)
|
package/lib/runtime.js
CHANGED
|
@@ -74,7 +74,8 @@ function executeScriptHelper(script, statements, options, locals) {
|
|
|
74
74
|
// Jump?
|
|
75
75
|
} else if (statementKey === 'jump') {
|
|
76
76
|
// Evaluate the expression (if any)
|
|
77
|
-
if (!('expr' in statement.jump) ||
|
|
77
|
+
if (!('expr' in statement.jump) ||
|
|
78
|
+
valueBoolean(evaluateExpression(statement.jump.expr, options, locals, false, script, statement))) {
|
|
78
79
|
// Find the label
|
|
79
80
|
if (labelIndexes !== null && statement.jump.label in labelIndexes) {
|
|
80
81
|
ixStatement = labelIndexes[statement.jump.label];
|
|
@@ -222,7 +223,7 @@ export function evaluateExpression(expr, options = null, locals = null, builtins
|
|
|
222
223
|
if (funcName === 'if') {
|
|
223
224
|
const [valueExpr = null, trueExpr = null, falseExpr = null] = expr.function.args ?? [];
|
|
224
225
|
const value = (valueExpr !== null ? evaluateExpression(valueExpr, options, locals, builtins, script, statement) : false);
|
|
225
|
-
const resultExpr = (value ? trueExpr : falseExpr);
|
|
226
|
+
const resultExpr = (valueBoolean(value) ? trueExpr : falseExpr);
|
|
226
227
|
return resultExpr !== null ? evaluateExpression(resultExpr, options, locals, builtins, script, statement) : null;
|
|
227
228
|
}
|
|
228
229
|
|
package/lib/runtimeAsync.js
CHANGED
|
@@ -80,7 +80,7 @@ async function executeScriptHelperAsync(script, statements, options, locals) {
|
|
|
80
80
|
} else if (statementKey === 'jump') {
|
|
81
81
|
// Evaluate the expression (if any)
|
|
82
82
|
if (!('expr' in statement.jump) ||
|
|
83
|
-
await evaluateExpressionAsync(statement.jump.expr, options, locals, false, script, statement)) {
|
|
83
|
+
valueBoolean(await evaluateExpressionAsync(statement.jump.expr, options, locals, false, script, statement))) {
|
|
84
84
|
// Find the label
|
|
85
85
|
if (labelIndexes !== null && statement.jump.label in labelIndexes) {
|
|
86
86
|
ixStatement = labelIndexes[statement.jump.label];
|
|
@@ -289,7 +289,7 @@ export async function evaluateExpressionAsync(expr, options = null, locals = nul
|
|
|
289
289
|
if (funcName === 'if') {
|
|
290
290
|
const [valueExpr, trueExpr = null, falseExpr = null] = expr.function.args;
|
|
291
291
|
const value = await evaluateExpressionAsync(valueExpr, options, locals, builtins, script, statement);
|
|
292
|
-
const resultExpr = (value ? trueExpr : falseExpr);
|
|
292
|
+
const resultExpr = (valueBoolean(value) ? trueExpr : falseExpr);
|
|
293
293
|
return resultExpr !== null ? evaluateExpressionAsync(resultExpr, options, locals, builtins, script, statement) : null;
|
|
294
294
|
}
|
|
295
295
|
|