securemark 0.299.0 → 0.299.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.299.1
4
+
5
+ - Refactoring.
6
+
3
7
  ## 0.299.0
4
8
 
5
9
  - Add support for CRLF linebreaks.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! securemark v0.299.0 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
1
+ /*! securemark v0.299.1 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
2
2
  (function webpackUniversalModuleDefinition(root, factory) {
3
3
  if(typeof exports === 'object' && typeof module === 'object')
4
4
  module.exports = factory(require("Prism"), require("DOMPurify"));
@@ -4224,7 +4224,7 @@ function parse(source) {
4224
4224
  Object.defineProperty(exports, "__esModule", ({
4225
4225
  value: true
4226
4226
  }));
4227
- exports.escape = exports.invisibleGraphHTMLEntityNames = exports.invisibleBlankCharacters = exports.invisibleBlankHTMLEntityNames = exports.normalize = void 0;
4227
+ exports.escape = exports.invisibleGraphHTMLEntityNames = exports.invisibleBlankHTMLEntityNames = exports.normalize = void 0;
4228
4228
  const dom_1 = __webpack_require__(394);
4229
4229
  const UNICODE_REPLACEMENT_CHARACTER = '\uFFFD';
4230
4230
  function normalize(source) {
@@ -4251,7 +4251,6 @@ const parser = (el => entity => {
4251
4251
  return el.textContent;
4252
4252
  })((0, dom_1.html)('span'));
4253
4253
  exports.invisibleBlankHTMLEntityNames = invisibleHTMLEntityNames.filter(name => parser(`&${name};`).trimStart() === '');
4254
- exports.invisibleBlankCharacters = exports.invisibleBlankHTMLEntityNames.map(name => parser(`&${name};`));
4255
4254
  exports.invisibleGraphHTMLEntityNames = invisibleHTMLEntityNames.filter(name => parser(`&${name};`).trimStart() !== '');
4256
4255
  const unreadableEscapeHTMLEntityNames = invisibleHTMLEntityNames.filter(name => !['Tab', 'NewLine', 'NonBreakingSpace', 'nbsp', 'zwj', 'zwnj'].includes(name));
4257
4256
  const unreadableEscapeCharacters = unreadableEscapeHTMLEntityNames.map(name => parser(`&${name};`));
@@ -8962,9 +8961,9 @@ const combinator_1 = __webpack_require__(3484);
8962
8961
  const normalize_1 = __webpack_require__(4490);
8963
8962
  var blank;
8964
8963
  (function (blank) {
8965
- blank.line = new RegExp(/((?:^|\n)[^\S\r\n]*(?=\S))((?:[^\S\r\n]|\\(?=$|\s)|&IBHN;|[IBC]|<wbr ?>)+(?=$|\r?\n))/g.source.replace('IBHN', `(?:${normalize_1.invisibleBlankHTMLEntityNames.join('|')})`).replace('IBC', `${normalize_1.invisibleBlankCharacters.join('')}`), 'g');
8966
- blank.start = new RegExp(/(?:[^\S\r\n]|\\(?=$|\s)|&IBHN;|[IBC]|<wbr ?>)+/y.source.replace('IBHN', `(?:${normalize_1.invisibleBlankHTMLEntityNames.join('|')})`).replace('IBC', `${normalize_1.invisibleBlankCharacters.join('')}`), 'y');
8967
- blank.unit = new RegExp(/(?:[^\S\r\n]|\\(?=$|\s)|&IBHN;|[IBC]|<wbr ?>)/y.source.replace('IBHN', `(?:${normalize_1.invisibleBlankHTMLEntityNames.join('|')})`).replace('IBC', `${normalize_1.invisibleBlankCharacters.join('')}`), 'y');
8964
+ blank.line = new RegExp(/((?:^|\n)[^\S\r\n]*(?=\S))((?:[^\S\r\n]|\\(?=$|\s)|&IBHN;|<wbr ?>)+(?=$|\r?\n))/g.source.replace('IBHN', `(?:${normalize_1.invisibleBlankHTMLEntityNames.join('|')})`), 'g');
8965
+ blank.start = new RegExp(/(?:[^\S\r\n]|\\(?=$|\s)|&IBHN;|<wbr ?>)+/y.source.replace('IBHN', `(?:${normalize_1.invisibleBlankHTMLEntityNames.join('|')})`), 'y');
8966
+ blank.unit = new RegExp(/(?:[^\S\r\n]|\\(?=$|\s)|&IBHN;|<wbr ?>)/y.source.replace('IBHN', `(?:${normalize_1.invisibleBlankHTMLEntityNames.join('|')})`), 'y');
8968
8967
  })(blank || (blank = {}));
8969
8968
  function visualize(parser) {
8970
8969
  return (0, combinator_1.convert)(source => source.replace(blank.line, `$1${"\u001B" /* Command.Escape */}$2`), parser);
@@ -8976,15 +8975,15 @@ function blankWith(starts, delimiter) {
8976
8975
  return new RegExp([
8977
8976
  // 空行除去
8978
8977
  // 完全な空行はエスケープ済みなので再帰的バックトラックにはならない。
8979
- String.raw`(?:${starts}(?:\\?\s|&(?:${normalize_1.invisibleBlankHTMLEntityNames.join('|')});|[${normalize_1.invisibleBlankCharacters.join('')}]|<wbr ?>)*)?`, typeof delimiter === 'string' ? delimiter.replace(/[*+()\[\]]/g, '\\$&') : delimiter.source].join(''), 'y');
8978
+ String.raw`(?:${starts}(?:\\?\s|&(?:${normalize_1.invisibleBlankHTMLEntityNames.join('|')});|<wbr ?>)*)?`, typeof delimiter === 'string' ? delimiter.replace(/[*+()\[\]]/g, '\\$&') : delimiter.source].join(''), 'y');
8980
8979
  }
8981
8980
  exports.blankWith = blankWith;
8982
8981
  function beforeNonblankWith(delimiter) {
8983
- return new RegExp([typeof delimiter === 'string' ? delimiter.replace(/[*+()\[\]]/g, '\\$&') : delimiter.source, String.raw`(?!\\?\s|&(?:${normalize_1.invisibleBlankHTMLEntityNames.join('|')});|[${normalize_1.invisibleBlankCharacters.join('')}]|<wbr ?>)`].join(''), 'y');
8982
+ return new RegExp([typeof delimiter === 'string' ? delimiter.replace(/[*+()\[\]]/g, '\\$&') : delimiter.source, String.raw`(?!\\?\s|&(?:${normalize_1.invisibleBlankHTMLEntityNames.join('|')});|<wbr ?>)`].join(''), 'y');
8984
8983
  }
8985
8984
  exports.beforeNonblankWith = beforeNonblankWith;
8986
8985
  function afterNonblankWith(delimiter) {
8987
- return new RegExp([String.raw`(?<!\s|&(?:${normalize_1.invisibleBlankHTMLEntityNames.join('|')});|[${normalize_1.invisibleBlankCharacters.join('')}]|<wbr ?>)`, typeof delimiter === 'string' ? delimiter.replace(/[*+()\[\]]/g, '\\$&') : delimiter.source].join(''), 'y');
8986
+ return new RegExp([String.raw`(?<!\s|&(?:${normalize_1.invisibleBlankHTMLEntityNames.join('|')});|<wbr ?>)`, typeof delimiter === 'string' ? delimiter.replace(/[*+()\[\]]/g, '\\$&') : delimiter.source].join(''), 'y');
8988
8987
  }
8989
8988
  function isNonblankFirstLine(nodes) {
8990
8989
  if (nodes.length === 0) return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securemark",
3
- "version": "0.299.0",
3
+ "version": "0.299.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",
@@ -65,8 +65,7 @@ const parser = (el => (entity: string): string => {
65
65
  })(html('span'));
66
66
  export const invisibleBlankHTMLEntityNames: readonly string[] = invisibleHTMLEntityNames
67
67
  .filter(name => parser(`&${name};`).trimStart() === '');
68
- export const invisibleBlankCharacters: readonly string[] = invisibleBlankHTMLEntityNames
69
- .map(name => parser(`&${name};`));
68
+ assert(invisibleBlankHTMLEntityNames.every(name => /^\s$/.test(parser(`&${name};`))));
70
69
  export const invisibleGraphHTMLEntityNames: readonly string[] = invisibleHTMLEntityNames
71
70
  .filter(name => parser(`&${name};`).trimStart() !== '');
72
71
  const unreadableEscapeHTMLEntityNames = invisibleHTMLEntityNames.filter(name => ![
@@ -2,23 +2,20 @@ import { Parser, List, Node } from '../combinator/data/parser';
2
2
  import { Command } from './context';
3
3
  import { Flag } from './node';
4
4
  import { convert, fmap } from '../combinator';
5
- import { invisibleBlankHTMLEntityNames, invisibleBlankCharacters } from './api/normalize';
5
+ import { invisibleBlankHTMLEntityNames } from './api/normalize';
6
6
 
7
7
  namespace blank {
8
8
  export const line = new RegExp(
9
- /((?:^|\n)[^\S\r\n]*(?=\S))((?:[^\S\r\n]|\\(?=$|\s)|&IBHN;|[IBC]|<wbr ?>)+(?=$|\r?\n))/g.source
10
- .replace('IBHN', `(?:${invisibleBlankHTMLEntityNames.join('|')})`)
11
- .replace('IBC', `${invisibleBlankCharacters.join('')}`),
9
+ /((?:^|\n)[^\S\r\n]*(?=\S))((?:[^\S\r\n]|\\(?=$|\s)|&IBHN;|<wbr ?>)+(?=$|\r?\n))/g.source
10
+ .replace('IBHN', `(?:${invisibleBlankHTMLEntityNames.join('|')})`),
12
11
  'g');
13
12
  export const start = new RegExp(
14
- /(?:[^\S\r\n]|\\(?=$|\s)|&IBHN;|[IBC]|<wbr ?>)+/y.source
15
- .replace('IBHN', `(?:${invisibleBlankHTMLEntityNames.join('|')})`)
16
- .replace('IBC', `${invisibleBlankCharacters.join('')}`),
13
+ /(?:[^\S\r\n]|\\(?=$|\s)|&IBHN;|<wbr ?>)+/y.source
14
+ .replace('IBHN', `(?:${invisibleBlankHTMLEntityNames.join('|')})`),
17
15
  'y');
18
16
  export const unit = new RegExp(
19
- /(?:[^\S\r\n]|\\(?=$|\s)|&IBHN;|[IBC]|<wbr ?>)/y.source
20
- .replace('IBHN', `(?:${invisibleBlankHTMLEntityNames.join('|')})`)
21
- .replace('IBC', `${invisibleBlankCharacters.join('')}`),
17
+ /(?:[^\S\r\n]|\\(?=$|\s)|&IBHN;|<wbr ?>)/y.source
18
+ .replace('IBHN', `(?:${invisibleBlankHTMLEntityNames.join('|')})`),
22
19
  'y');
23
20
  }
24
21
 
@@ -34,7 +31,7 @@ export function blankWith(starts: '\n', delimiter: string | RegExp): RegExp {
34
31
  return new RegExp([
35
32
  // 空行除去
36
33
  // 完全な空行はエスケープ済みなので再帰的バックトラックにはならない。
37
- String.raw`(?:${starts}(?:\\?\s|&(?:${invisibleBlankHTMLEntityNames.join('|')});|[${invisibleBlankCharacters.join('')}]|<wbr ?>)*)?`,
34
+ String.raw`(?:${starts}(?:\\?\s|&(?:${invisibleBlankHTMLEntityNames.join('|')});|<wbr ?>)*)?`,
38
35
  typeof delimiter === 'string'
39
36
  ? delimiter.replace(/[*+()\[\]]/g, '\\$&')
40
37
  : delimiter.source,
@@ -45,12 +42,12 @@ export function beforeNonblankWith(delimiter: string | RegExp): RegExp {
45
42
  typeof delimiter === 'string'
46
43
  ? delimiter.replace(/[*+()\[\]]/g, '\\$&')
47
44
  : delimiter.source,
48
- String.raw`(?!\\?\s|&(?:${invisibleBlankHTMLEntityNames.join('|')});|[${invisibleBlankCharacters.join('')}]|<wbr ?>)`,
45
+ String.raw`(?!\\?\s|&(?:${invisibleBlankHTMLEntityNames.join('|')});|<wbr ?>)`,
49
46
  ].join(''), 'y');
50
47
  }
51
48
  function afterNonblankWith(delimiter: string | RegExp): RegExp {
52
49
  return new RegExp([
53
- String.raw`(?<!\s|&(?:${invisibleBlankHTMLEntityNames.join('|')});|[${invisibleBlankCharacters.join('')}]|<wbr ?>)`,
50
+ String.raw`(?<!\s|&(?:${invisibleBlankHTMLEntityNames.join('|')});|<wbr ?>)`,
54
51
  typeof delimiter === 'string'
55
52
  ? delimiter.replace(/[*+()\[\]]/g, '\\$&')
56
53
  : delimiter.source,