bare-script 3.8.10 → 3.8.13

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.
@@ -90,14 +90,31 @@ async function baredocMain(url, title, menuLinks, groupURLs):
90
90
  return
91
91
  endif
92
92
 
93
+ # Fetch the group content URLs
94
+ groupContent = {}
95
+ if groupURLs != null:
96
+ # Fetch the content URLs
97
+ groupURLArray = []
98
+ groupNames = arraySort(objectKeys(groupURLs))
99
+ for groupName in groupNames:
100
+ arrayPush(groupURLArray, objectGet(groupURLs, groupName))
101
+ endfor
102
+ groupContentArray = systemFetch(groupURLArray)
103
+
104
+ # Assign the group contents
105
+ for groupName, ixGroupName in groupNames:
106
+ objectSet(groupContent, groupName, arrayGet(groupContentArray, ixGroupName))
107
+ endfor
108
+ endif
109
+
93
110
  # Render the page
94
111
  title = if(title != null && !objectHas(args, 'url'), title, url)
95
112
  if group != null:
96
- baredocGroupPage(args, title, groupURLs, groups, group)
113
+ baredocGroupPage(args, title, groupURLs, groupContent, groups, group)
97
114
  elif single:
98
- baredocSinglePage(args, title, menuLinks, groupURLs, groups)
115
+ baredocSinglePage(args, title, menuLinks, groupURLs, groupContent, groups)
99
116
  else:
100
- baredocIndexPage(args, title, menuLinks, groupURLs, groups)
117
+ baredocIndexPage(args, title, menuLinks, groupURLs, groupContent, groups)
101
118
  endif
102
119
  endfunction
103
120
 
@@ -122,7 +139,7 @@ endfunction
122
139
 
123
140
 
124
141
  # Render a library documentation index page
125
- async function baredocIndexPage(args, title, menuLinks, groupURLs, groups):
142
+ function baredocIndexPage(args, title, menuLinks, groupURLs, groupContent, groups):
126
143
  publish = objectGet(args, 'publish')
127
144
 
128
145
  # Render the menu and title
@@ -139,9 +156,9 @@ async function baredocIndexPage(args, title, menuLinks, groupURLs, groups):
139
156
  markdownPrint('# ' + markdownEscape(title))
140
157
 
141
158
  # Render the index Markdown, if any
142
- if groupURLs != null && objectHas(groupURLs, ''):
159
+ if objectHas(groupContent, ''):
143
160
  rootURL = objectGet(groupURLs, '')
144
- rootMarkdown = systemFetch(rootURL)
161
+ rootMarkdown = objectGet(groupContent, '')
145
162
  markdownPrint('', if(rootMarkdown != null, rootMarkdown, '**Error:** Failed to load "' + markdownEscape(rootURL) + '"'))
146
163
  endif
147
164
 
@@ -159,7 +176,7 @@ endfunction
159
176
 
160
177
 
161
178
  # Render the single-page library documentation
162
- async function baredocSinglePage(args, title, menuLinks, groupURLs, groups):
179
+ function baredocSinglePage(args, title, menuLinks, groupURLs, groupContent, groups):
163
180
  publish = objectGet(args, 'publish')
164
181
 
165
182
  # Render the menu and title
@@ -176,9 +193,9 @@ async function baredocSinglePage(args, title, menuLinks, groupURLs, groups):
176
193
  markdownPrint('# ' + markdownEscape(title))
177
194
 
178
195
  # Render the index Markdown, if any
179
- if groupURLs != null && objectHas(groupURLs, ''):
196
+ if objectHas(groupContent, ''):
180
197
  rootURL = objectGet(groupURLs, '')
181
- rootMarkdown = systemFetch(rootURL)
198
+ rootMarkdown = objectGet(groupContent, '')
182
199
  markdownPrint('', if(rootMarkdown != null, rootMarkdown, '**Error:** Failed to load "' + markdownEscape(rootURL) + '"'))
183
200
  endif
184
201
 
@@ -196,13 +213,13 @@ async function baredocSinglePage(args, title, menuLinks, groupURLs, groups):
196
213
  # Render the library function index
197
214
  for groupName in arraySort(objectKeys(groups)):
198
215
  markdownPrint('', '---', '')
199
- baredocGroupPage(args, title, groupURLs, groups, groupName)
216
+ baredocGroupPage(args, title, groupURLs, groupContent, groups, groupName)
200
217
  endfor
201
218
  endfunction
202
219
 
203
220
 
204
221
  # Render a library documentation group page
205
- async function baredocGroupPage(args, title, groupURLs, groups, groupName):
222
+ function baredocGroupPage(args, title, groupURLs, groupContent, groups, groupName):
206
223
  publish = objectGet(args, 'publish')
207
224
  single = objectGet(args, 'single')
208
225
  baseHeader = if(single, '##', '#')
@@ -227,11 +244,10 @@ async function baredocGroupPage(args, title, groupURLs, groups, groupName):
227
244
  markdownPrint('', argsLink(baredocArguments, 'Back to top', null, false, '_top'))
228
245
  endif
229
246
 
230
-
231
247
  # Render the group Markdown, if any
232
- if groupURLs != null && objectHas(groupURLs, groupName):
248
+ if objectHas(groupContent, groupName):
233
249
  groupURL = objectGet(groupURLs, groupName)
234
- groupMarkdown = systemFetch(groupURL)
250
+ groupMarkdown = objectGet(groupContent, groupName)
235
251
  markdownPrint('', if(groupMarkdown != null, groupMarkdown, '**Error:** Failed to load "' + markdownEscape(groupURL) + '"'))
236
252
  endif
237
253
 
@@ -44,25 +44,9 @@ diffTypes = schemaParse( \
44
44
  function diffLines(left, right):
45
45
  diffs = []
46
46
 
47
- # Split the left into an array of lines
48
- if systemType(left) == 'array':
49
- leftLines = []
50
- for leftPart in left:
51
- arrayExtend(leftLines, regexSplit(diffRegexLineSplit, leftPart))
52
- endfor
53
- else:
54
- leftLines = regexSplit(diffRegexLineSplit, left)
55
- endif
56
-
57
- # Split the right into an array of lines
58
- if systemType(right) == 'array':
59
- rightLines = []
60
- for rightPart in right:
61
- arrayExtend(rightLines, regexSplit(diffRegexLineSplit, rightPart))
62
- endfor
63
- else:
64
- rightLines = regexSplit(diffRegexLineSplit, right)
65
- endif
47
+ # Convert inputs to arrays of lines
48
+ leftLines = diffLinesToArray(left)
49
+ rightLines = diffLinesToArray(right)
66
50
 
67
51
  # Compute the differences
68
52
  ixLeft = 0
@@ -97,25 +81,23 @@ function diffLines(left, right):
97
81
  endif
98
82
 
99
83
  # Look ahead to find next matching point
100
- foundMatch = false
84
+ matchIxLeft = null
85
+ matchIxRight = null
101
86
  ixLeftTmp = ixLeft
102
- while ixLeftTmp < leftLength:
87
+ while ixLeftTmp < leftLength && matchIxLeft == null:
103
88
  ixRightTmp = ixRight
104
- while ixRightTmp < rightLength:
89
+ while ixRightTmp < rightLength && matchIxLeft == null:
105
90
  if arrayGet(leftLines, ixLeftTmp) == arrayGet(rightLines, ixRightTmp):
106
- foundMatch = true
107
- break
91
+ matchIxLeft = ixLeftTmp
92
+ matchIxRight = ixRightTmp
108
93
  endif
109
94
  ixRightTmp = ixRightTmp + 1
110
95
  endwhile
111
- if foundMatch:
112
- break
113
- endif
114
96
  ixLeftTmp = ixLeftTmp + 1
115
97
  endwhile
116
98
 
117
99
  # If no match found, use remaining lines
118
- if !foundMatch:
100
+ if matchIxLeft == null:
119
101
  if ixLeft < leftLength:
120
102
  arrayPush(diffs, {'type': 'Remove', 'lines': arraySlice(leftLines, ixLeft)})
121
103
  ixLeft = leftLength
@@ -128,15 +110,15 @@ function diffLines(left, right):
128
110
  endif
129
111
 
130
112
  # Add removed lines if any
131
- if ixLeftTmp > ixLeft:
132
- arrayPush(diffs, {'type': 'Remove', 'lines': arraySlice(leftLines, ixLeft, ixLeftTmp)})
133
- ixLeft = ixLeftTmp
113
+ if matchIxLeft > ixLeft:
114
+ arrayPush(diffs, {'type': 'Remove', 'lines': arraySlice(leftLines, ixLeft, matchIxLeft)})
115
+ ixLeft = matchIxLeft
134
116
  endif
135
117
 
136
118
  # Add added lines if any
137
- if ixRightTmp > ixRight:
138
- arrayPush(diffs, {'type': 'Add', 'lines': arraySlice(rightLines, ixRight, ixRightTmp)})
139
- ixRight = ixRightTmp
119
+ if matchIxRight > ixRight:
120
+ arrayPush(diffs, {'type': 'Add', 'lines': arraySlice(rightLines, ixRight, matchIxRight)})
121
+ ixRight = matchIxRight
140
122
  endif
141
123
  endwhile
142
124
 
@@ -144,5 +126,25 @@ function diffLines(left, right):
144
126
  endfunction
145
127
 
146
128
 
129
+ # Helper function to convert input to array of lines
130
+ function diffLinesToArray(input):
131
+ # Array input?
132
+ if systemType(input) == 'array':
133
+ lines = []
134
+ for part in input:
135
+ arrayExtend(lines, regexSplit(diffRegexLineSplit, part))
136
+ endfor
137
+ return lines
138
+ endif
139
+
140
+ # String input
141
+ lines = regexSplit(diffRegexLineSplit, input)
142
+ if arrayLength(lines) == 1 && arrayGet(lines, 0) == '':
143
+ return []
144
+ endif
145
+ return lines
146
+ endfunction
147
+
148
+
147
149
  # Regex for splitting lines
148
150
  diffRegexLineSplit = regexNew('\r?\n')
@@ -442,7 +442,7 @@ endfunction
442
442
 
443
443
 
444
444
  # $function: markdownElements
445
- # $group: Markdown
445
+ # $group: markdownUp.bare: markdown
446
446
  # $doc: Generate an element model from a Markdown model
447
447
  # $arg markdownModel: The [Markdown model](https://craigahobbs.github.io/markdown-model/model/#var.vName='Markdown')
448
448
  # $arg generic: Optional (default is false). If true, render markdown elements in a generic context.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "bare-script",
4
- "version": "3.8.10",
4
+ "version": "3.8.13",
5
5
  "description": "BareScript; a lightweight scripting and expression language",
6
6
  "keywords": [
7
7
  "expression",