securemark 0.225.0 → 0.225.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.225.1
4
+
5
+ - Refactoring.
6
+
3
7
  ## 0.225.0
4
8
 
5
9
  - Refine some parsers to disallow trailing whitespace.
@@ -1,4 +1,4 @@
1
- /*! securemark v0.225.0 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED */
1
+ /*! securemark v0.225.1 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED */
2
2
  require = function () {
3
3
  function r(e, n, t) {
4
4
  function o(i, f) {
@@ -9056,26 +9056,31 @@ require = function () {
9056
9056
  }
9057
9057
  exports.trimNode = trimNode;
9058
9058
  function trimNodeStart(nodes) {
9059
- const skip = nodes.length > 0 && typeof nodes[nodes.length - 1] === 'object' && nodes[nodes.length - 1]['className'] === 'indexer' ? [nodes.pop()] : [];
9060
- for (let first = nodes[0]; nodes.length > 0 && !isVisible(first, 0) && !(typeof first === 'object' && first.className === 'comment');) {
9061
- if (typeof first === 'string') {
9062
- const pos = first.length - first.trimStart().length;
9059
+ for (let node = nodes[0]; nodes.length > 0 && !isVisible(node = nodes[0], 0);) {
9060
+ if (nodes.length === 1 && typeof node === 'object' && node.className === 'indexer')
9061
+ break;
9062
+ if (typeof node === 'object' && node.className === 'comment')
9063
+ break;
9064
+ if (typeof node === 'string') {
9065
+ const pos = node.length - node.trimStart().length;
9063
9066
  if (pos > 0) {
9064
- nodes[0] = first.slice(pos);
9067
+ nodes[0] = node.slice(pos);
9065
9068
  break;
9066
9069
  }
9067
9070
  }
9068
- nodes.pop();
9071
+ nodes.shift();
9069
9072
  }
9070
- return (0, array_1.push)(nodes, skip);
9073
+ return nodes;
9071
9074
  }
9072
9075
  function trimNodeEnd(nodes) {
9073
9076
  const skip = nodes.length > 0 && typeof nodes[nodes.length - 1] === 'object' && nodes[nodes.length - 1]['className'] === 'indexer' ? [nodes.pop()] : [];
9074
- for (let last = nodes[0]; nodes.length > 0 && !isVisible(last = nodes[nodes.length - 1], -1) && !(typeof last === 'object' && last.className === 'comment');) {
9075
- if (typeof last === 'string') {
9076
- const pos = last.trimEnd().length;
9077
+ for (let node = nodes[0]; nodes.length > 0 && !isVisible(node = nodes[nodes.length - 1], -1);) {
9078
+ if (typeof node === 'object' && node.className === 'comment')
9079
+ break;
9080
+ if (typeof node === 'string') {
9081
+ const pos = node.trimEnd().length;
9077
9082
  if (pos > 0) {
9078
- nodes[nodes.length - 1] = last.slice(0, pos);
9083
+ nodes[nodes.length - 1] = node.slice(0, pos);
9079
9084
  break;
9080
9085
  }
9081
9086
  }
package/package-lock.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securemark",
3
- "version": "0.225.0",
3
+ "version": "0.225.1",
4
4
  "lockfileVersion": 1,
5
5
  "requires": true,
6
6
  "dependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securemark",
3
- "version": "0.225.0",
3
+ "version": "0.225.1",
4
4
  "description": "Secure markdown renderer working on browsers for user input data.",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/falsandtru/securemark",
@@ -172,28 +172,19 @@ export function trimNode(nodes: (HTMLElement | string)[]): (HTMLElement | string
172
172
  return trimNodeStart(trimNodeEnd(nodes));
173
173
  }
174
174
  function trimNodeStart(nodes: (HTMLElement | string)[]): (HTMLElement | string)[] {
175
- const skip = nodes.length > 0 &&
176
- typeof nodes[nodes.length - 1] === 'object' &&
177
- nodes[nodes.length - 1]['className'] === 'indexer'
178
- ? [nodes.pop()!]
179
- : [];
180
- for (
181
- let first = nodes[0];
182
- nodes.length > 0 &&
183
- !isVisible(first, 0) &&
184
- !(typeof first === 'object' && first.className === 'comment');
185
- ) {
186
- assert(nodes.length > 0);
187
- if (typeof first === 'string') {
188
- const pos = first.length - first.trimStart().length;
175
+ for (let node = nodes[0]; nodes.length > 0 && !isVisible(node = nodes[0], 0);) {
176
+ if (nodes.length === 1 && typeof node === 'object' && node.className === 'indexer') break;
177
+ if (typeof node === 'object' && node.className === 'comment') break;
178
+ if (typeof node === 'string') {
179
+ const pos = node.length - node.trimStart().length;
189
180
  if (pos > 0) {
190
- nodes[0] = first.slice(pos);
181
+ nodes[0] = node.slice(pos);
191
182
  break;
192
183
  }
193
184
  }
194
- nodes.pop();
185
+ nodes.shift();
195
186
  }
196
- return push(nodes, skip);
187
+ return nodes;
197
188
  }
198
189
  export function trimNodeEnd(nodes: (HTMLElement | string)[]): (HTMLElement | string)[] {
199
190
  const skip = nodes.length > 0 &&
@@ -201,17 +192,12 @@ export function trimNodeEnd(nodes: (HTMLElement | string)[]): (HTMLElement | str
201
192
  nodes[nodes.length - 1]['className'] === 'indexer'
202
193
  ? [nodes.pop()!]
203
194
  : [];
204
- for (
205
- let last = nodes[0];
206
- nodes.length > 0 &&
207
- !isVisible(last = nodes[nodes.length - 1], -1) &&
208
- !(typeof last === 'object' && last.className === 'comment');
209
- ) {
210
- assert(nodes.length > 0);
211
- if (typeof last === 'string') {
212
- const pos = last.trimEnd().length;
195
+ for (let node = nodes[0]; nodes.length > 0 && !isVisible(node = nodes[nodes.length - 1], -1);) {
196
+ if (typeof node === 'object' && node.className === 'comment') break;
197
+ if (typeof node === 'string') {
198
+ const pos = node.trimEnd().length;
213
199
  if (pos > 0) {
214
- nodes[nodes.length - 1] = last.slice(0, pos);
200
+ nodes[nodes.length - 1] = node.slice(0, pos);
215
201
  break;
216
202
  }
217
203
  }