marked-underline 1.0.0 → 1.0.2

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/README.md CHANGED
@@ -2,16 +2,33 @@
2
2
 
3
3
  Add underline markup to Markdown by repurposing `_Text_`.
4
4
 
5
+ With the flag justUnderline set true, it will strip double and triple underline markup and leave it normal rather than
6
+
5
7
  # Usage
6
8
  <!-- Show most examples of how to use this extension -->
7
9
 
10
+ ## Default
11
+
12
+ ```js
13
+ const marked = require("marked");
14
+ const markedUnderline = require("marked-underline");
15
+
16
+ marked.use(markedUnderline());
17
+
18
+ const html = marked.parse("This is _underlined_.\nThis is __strong__.");
19
+ console.log(html);
20
+ // <p>This is <u>underlined</u>.\nThis is <strong>strong</strong>.</p>
21
+ ```
22
+
23
+ ## justUnderline enabled
24
+
8
25
  ```js
9
26
  const marked = require("marked");
10
- const markedSubSuper = require("marked-underline");
27
+ const markedUnderline = require("marked-underline");
11
28
 
12
- marked.use(markedSubSuper());
29
+ marked.use(markedUnderline({justUnderline: true}));
13
30
 
14
- const html = marked.parse("This is _underlined_.");
31
+ const html = marked.parse("This is _underlined_.\nThis is __normal__.");
15
32
  console.log(html);
16
- // <p>This is <u>underlined</u>.</p>
33
+ // <p>This is <u>underlined</u>.\nThis is normal.</p>
17
34
  ```
package/lib/index.cjs CHANGED
@@ -1,25 +1,29 @@
1
1
  'use strict';
2
2
 
3
- function index() {
3
+ function index({ justUnderline = false }) {
4
4
  return {
5
5
  extensions: [
6
6
  {
7
7
  name : 'underline',
8
8
  level : 'inline',
9
- start(src) { return src.match(/\b_([^_]*?)_\b/m)?.index;},
9
+ start(src) { return src.match(/\b_([^_]*?)_\b/m)?.index; },
10
10
  tokenizer(src, tokens) {
11
- const regex = /^\b_([^_]*?)_\b/m;
12
- const match = regex.exec(src);
13
- if(match?.length) {
14
- return {
15
- type : 'underline',
16
- raw : match[0],
17
- tokens : this.lexer.inlineTokens(match[1])
18
- };
11
+ const regex = /^\b(_{1,3})([^_]*?)(_{1,3})\b/m;
12
+ const match = regex.exec(src);
13
+ if (match?.length) {
14
+ if (match[1].length === match[3].length) {
15
+ const returnObj = {
16
+ type: 'underline',
17
+ raw: match[0],
18
+ tokens: this.lexer.inlineTokens(match[2]),
19
+ skip: justUnderline ? (match[1].length > 1) : false
20
+ };
21
+ if (justUnderline || (!justUnderline && (match[1].length === 1))) return returnObj;
22
+ }
19
23
  }
20
24
  },
21
- renderer(token) {
22
- return `<u>${this.parser.parseInline(token.tokens)}</u>`;
25
+ renderer(token) {
26
+ return `${token.skip ? '' : '<u>'}${this.parser.parseInline(token.tokens)}${token.skip ? '' : '</u>'}`;
23
27
  }
24
28
  }
25
29
  ]
package/lib/index.umd.js CHANGED
@@ -4,26 +4,30 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global["subsuper-text"] = factory());
5
5
  })(this, (function () { 'use strict';
6
6
 
7
- function index() {
7
+ function index({ justUnderline = false }) {
8
8
  return {
9
9
  extensions: [
10
10
  {
11
11
  name : 'underline',
12
12
  level : 'inline',
13
- start(src) { return src.match(/\b_([^_]*?)_\b/m)?.index;},
13
+ start(src) { return src.match(/\b_([^_]*?)_\b/m)?.index; },
14
14
  tokenizer(src, tokens) {
15
- const regex = /^\b_([^_]*?)_\b/m;
16
- const match = regex.exec(src);
17
- if(match?.length) {
18
- return {
19
- type : 'underline',
20
- raw : match[0],
21
- tokens : this.lexer.inlineTokens(match[1])
22
- };
15
+ const regex = /^\b(_{1,3})([^_]*?)(_{1,3})\b/m;
16
+ const match = regex.exec(src);
17
+ if (match?.length) {
18
+ if (match[1].length === match[3].length) {
19
+ const returnObj = {
20
+ type: 'underline',
21
+ raw: match[0],
22
+ tokens: this.lexer.inlineTokens(match[2]),
23
+ skip: justUnderline ? (match[1].length > 1) : false
24
+ };
25
+ if (justUnderline || (!justUnderline && (match[1].length === 1))) return returnObj;
26
+ }
23
27
  }
24
28
  },
25
- renderer(token) {
26
- return `<u>${this.parser.parseInline(token.tokens)}</u>`;
29
+ renderer(token) {
30
+ return `${token.skip ? '' : '<u>'}${this.parser.parseInline(token.tokens)}${token.skip ? '' : '</u>'}`;
27
31
  }
28
32
  }
29
33
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marked-underline",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Underline markup for Marked.js",
5
5
  "main": "./lib/index.cjs",
6
6
  "module": "./src/index.js",
@@ -60,481 +60,5 @@
60
60
  "lib": "lib"
61
61
  },
62
62
  "dependencies": {
63
- "acorn": "^8.11.2",
64
- "acorn-jsx": "^5.3.2",
65
- "agent-base": "^7.1.0",
66
- "aggregate-error": "^3.1.0",
67
- "ajv": "^6.12.6",
68
- "ansi-escapes": "^4.3.2",
69
- "ansi-regex": "^5.0.1",
70
- "ansi-styles": "^4.3.0",
71
- "any-promise": "^1.3.0",
72
- "anymatch": "^3.1.3",
73
- "argparse": "^1.0.10",
74
- "argv-formatter": "^1.0.0",
75
- "array-buffer-byte-length": "^1.0.2",
76
- "array-ify": "^1.0.0",
77
- "array-includes": "^3.1.8",
78
- "array.prototype.findlastindex": "^1.2.5",
79
- "array.prototype.flat": "^1.3.2",
80
- "array.prototype.flatmap": "^1.3.2",
81
- "arraybuffer.prototype.slice": "^1.0.4",
82
- "available-typed-arrays": "^1.0.7",
83
- "babel-plugin-istanbul": "^6.1.1",
84
- "babel-plugin-jest-hoist": "^29.6.3",
85
- "babel-plugin-polyfill-corejs2": "^0.4.11",
86
- "babel-plugin-polyfill-corejs3": "^0.10.6",
87
- "babel-plugin-polyfill-regenerator": "^0.6.2",
88
- "babel-preset-current-node-syntax": "^1.0.1",
89
- "babel-preset-jest": "^29.6.3",
90
- "balanced-match": "^1.0.2",
91
- "before-after-hook": "^3.0.2",
92
- "bottleneck": "^2.19.5",
93
- "brace-expansion": "^1.1.11",
94
- "braces": "^3.0.2",
95
- "browserslist": "^4.24.3",
96
- "bser": "^2.1.1",
97
- "buffer-from": "^1.1.2",
98
- "builtins": "^5.0.1",
99
- "call-bind": "^1.0.8",
100
- "call-bind-apply-helpers": "^1.0.1",
101
- "call-bound": "^1.0.3",
102
- "callsites": "^3.1.0",
103
- "camelcase": "^5.3.1",
104
- "caniuse-lite": "^1.0.30001690",
105
- "chalk": "^4.1.2",
106
- "char-regex": "^1.0.2",
107
- "ci-info": "^3.3.0",
108
- "cjs-module-lexer": "^1.2.3",
109
- "clean-stack": "^2.2.0",
110
- "cli-highlight": "^2.1.11",
111
- "cli-table3": "^0.6.5",
112
- "cliui": "^8.0.1",
113
- "co": "^4.6.0",
114
- "coa": "^2.0.2",
115
- "collect-v8-coverage": "^1.0.2",
116
- "color-convert": "^2.0.1",
117
- "color-name": "^1.1.4",
118
- "commondir": "^1.0.1",
119
- "compare-func": "^2.0.0",
120
- "concat-map": "^0.0.1",
121
- "config-chain": "^1.1.13",
122
- "conventional-changelog-angular": "^8.0.0",
123
- "conventional-changelog-writer": "^8.0.0",
124
- "conventional-commits-filter": "^5.0.0",
125
- "conventional-commits-parser": "^6.0.0",
126
- "convert-hrtime": "^5.0.0",
127
- "convert-source-map": "^1.8.0",
128
- "core-js-compat": "^3.38.1",
129
- "core-util-is": "^1.0.3",
130
- "cosmiconfig": "^9.0.0",
131
- "create-jest": "^29.7.0",
132
- "cross-spawn": "^7.0.3",
133
- "crypto-random-string": "^4.0.0",
134
- "data-view-buffer": "^1.0.2",
135
- "data-view-byte-length": "^1.0.2",
136
- "data-view-byte-offset": "^1.0.1",
137
- "debug": "^4.3.4",
138
- "dedent": "^1.5.1",
139
- "deep-extend": "^0.6.0",
140
- "deep-is": "^0.1.4",
141
- "deepmerge": "^4.2.2",
142
- "define-data-property": "^1.1.4",
143
- "define-properties": "^1.2.1",
144
- "detect-newline": "^3.1.0",
145
- "diff": "^6.0.0",
146
- "diff-sequences": "^29.6.3",
147
- "dir-glob": "^3.0.1",
148
- "doctrine": "^3.0.0",
149
- "dot-prop": "^5.3.0",
150
- "dunder-proto": "^1.0.1",
151
- "duplexer2": "^0.1.4",
152
- "electron-to-chromium": "^1.5.76",
153
- "emittery": "^0.13.1",
154
- "emoji-regex": "^8.0.0",
155
- "emojilib": "^2.4.0",
156
- "entities": "^4.5.0",
157
- "env-ci": "^11.0.0",
158
- "env-paths": "^2.2.1",
159
- "environment": "^1.1.0",
160
- "error-ex": "^1.3.2",
161
- "es-abstract": "^1.23.9",
162
- "es-define-property": "^1.0.1",
163
- "es-errors": "^1.3.0",
164
- "es-object-atoms": "^1.0.0",
165
- "es-set-tostringtag": "^2.1.0",
166
- "es-shim-unscopables": "^1.0.2",
167
- "es-to-primitive": "^1.3.0",
168
- "escalade": "^3.2.0",
169
- "escape-string-regexp": "^4.0.0",
170
- "eslint-import-resolver-node": "^0.3.9",
171
- "eslint-module-utils": "^2.12.0",
172
- "eslint-plugin-es": "^4.1.0",
173
- "eslint-plugin-n": "^15.2.2",
174
- "eslint-scope": "^7.2.2",
175
- "eslint-utils": "^2.1.0",
176
- "eslint-visitor-keys": "^3.4.3",
177
- "espree": "^9.6.1",
178
- "esprima": "^4.0.1",
179
- "esquery": "^1.4.2",
180
- "esrecurse": "^4.3.0",
181
- "estraverse": "^5.3.0",
182
- "estree-walker": "^2.0.2",
183
- "esutils": "^2.0.3",
184
- "execa": "^5.1.1",
185
- "exit": "^0.1.2",
186
- "expect": "^29.7.0",
187
- "fast-deep-equal": "^3.1.3",
188
- "fast-glob": "^3.3.2",
189
- "fast-json-stable-stringify": "^2.1.0",
190
- "fast-levenshtein": "^2.0.6",
191
- "fastq": "^1.13.0",
192
- "fb-watchman": "^2.0.2",
193
- "figures": "^6.1.0",
194
- "file-entry-cache": "^6.0.1",
195
- "fill-range": "^7.0.1",
196
- "find-up": "^2.1.0",
197
- "find-up-simple": "^1.0.0",
198
- "find-versions": "^6.0.0",
199
- "flat-cache": "^3.0.4",
200
- "flatted": "^3.2.4",
201
- "for-each": "^0.3.3",
202
- "from2": "^2.3.0",
203
- "front-matter": "^4.0.2",
204
- "fs-extra": "^11.1.0",
205
- "fs.realpath": "^1.0.0",
206
- "function-bind": "^1.1.2",
207
- "function-timeout": "^1.0.2",
208
- "function.prototype.name": "^1.1.8",
209
- "functions-have-names": "^1.2.3",
210
- "gensync": "^1.0.0-beta.2",
211
- "get-caller-file": "^2.0.5",
212
- "get-intrinsic": "^1.2.7",
213
- "get-package-type": "^0.1.0",
214
- "get-proto": "^1.0.1",
215
- "get-stream": "^6.0.1",
216
- "get-symbol-description": "^1.1.0",
217
- "git-log-parser": "^1.2.0",
218
- "glob": "^7.2.0",
219
- "glob-parent": "^5.1.2",
220
- "globals": "^13.23.0",
221
- "globalthis": "^1.0.4",
222
- "globby": "^14.0.0",
223
- "gopd": "^1.2.0",
224
- "graceful-fs": "^4.2.10",
225
- "graphemer": "^1.4.0",
226
- "handlebars": "^4.7.8",
227
- "has-bigints": "^1.1.0",
228
- "has-flag": "^4.0.0",
229
- "has-property-descriptors": "^1.0.2",
230
- "has-proto": "^1.2.0",
231
- "has-symbols": "^1.1.0",
232
- "has-tostringtag": "^1.0.2",
233
- "hasown": "^2.0.2",
234
- "highlight.js": "^10.7.3",
235
- "hook-std": "^3.0.0",
236
- "hosted-git-info": "^7.0.2",
237
- "html-escaper": "^2.0.2",
238
- "http-proxy-agent": "^7.0.0",
239
- "https-proxy-agent": "^7.0.0",
240
- "human-signals": "^2.1.0",
241
- "ignore": "^5.3.0",
242
- "import-fresh": "^3.3.0",
243
- "import-from-esm": "^2.0.0",
244
- "import-local": "^3.0.3",
245
- "import-meta-resolve": "^4.1.0",
246
- "imurmurhash": "^0.1.4",
247
- "indent-string": "^4.0.0",
248
- "index-to-position": "^0.1.2",
249
- "inflight": "^1.0.6",
250
- "inherits": "^2.0.4",
251
- "ini": "^1.3.8",
252
- "internal-slot": "^1.1.0",
253
- "into-stream": "^7.0.0",
254
- "is-array-buffer": "^3.0.5",
255
- "is-arrayish": "^0.2.1",
256
- "is-async-function": "^2.1.0",
257
- "is-bigint": "^1.1.0",
258
- "is-boolean-object": "^1.2.1",
259
- "is-callable": "^1.2.7",
260
- "is-core-module": "^2.16.1",
261
- "is-data-view": "^1.0.2",
262
- "is-date-object": "^1.1.0",
263
- "is-extglob": "^2.1.1",
264
- "is-finalizationregistry": "^1.1.1",
265
- "is-fullwidth-code-point": "^3.0.0",
266
- "is-generator-fn": "^2.1.0",
267
- "is-generator-function": "^1.1.0",
268
- "is-glob": "^4.0.3",
269
- "is-map": "^2.0.3",
270
- "is-module": "^1.0.0",
271
- "is-number": "^7.0.0",
272
- "is-number-object": "^1.1.1",
273
- "is-obj": "^2.0.0",
274
- "is-path-inside": "^3.0.3",
275
- "is-plain-obj": "^4.1.0",
276
- "is-reference": "^1.2.1",
277
- "is-regex": "^1.2.1",
278
- "is-set": "^2.0.3",
279
- "is-shared-array-buffer": "^1.0.4",
280
- "is-stream": "^2.0.1",
281
- "is-string": "^1.1.1",
282
- "is-symbol": "^1.1.1",
283
- "is-typed-array": "^1.1.15",
284
- "is-unicode-supported": "^2.0.0",
285
- "is-weakmap": "^2.0.2",
286
- "is-weakref": "^1.1.0",
287
- "is-weakset": "^2.0.4",
288
- "isarray": "^1.0.0",
289
- "isexe": "^2.0.0",
290
- "issue-parser": "^7.0.1",
291
- "istanbul-lib-coverage": "^3.2.0",
292
- "istanbul-lib-instrument": "^5.1.0",
293
- "istanbul-lib-report": "^3.0.1",
294
- "istanbul-lib-source-maps": "^4.0.1",
295
- "istanbul-reports": "^3.1.6",
296
- "java-properties": "^1.0.2",
297
- "jest-changed-files": "^29.7.0",
298
- "jest-circus": "^29.7.0",
299
- "jest-config": "^29.7.0",
300
- "jest-diff": "^29.7.0",
301
- "jest-docblock": "^29.7.0",
302
- "jest-each": "^29.7.0",
303
- "jest-environment-node": "^29.7.0",
304
- "jest-get-type": "^29.6.3",
305
- "jest-haste-map": "^29.7.0",
306
- "jest-leak-detector": "^29.7.0",
307
- "jest-matcher-utils": "^29.7.0",
308
- "jest-message-util": "^29.7.0",
309
- "jest-mock": "^29.7.0",
310
- "jest-pnp-resolver": "^1.2.3",
311
- "jest-regex-util": "^29.6.3",
312
- "jest-resolve": "^29.7.0",
313
- "jest-resolve-dependencies": "^29.7.0",
314
- "jest-runner": "^29.7.0",
315
- "jest-runtime": "^29.7.0",
316
- "jest-snapshot": "^29.7.0",
317
- "jest-util": "^29.7.0",
318
- "jest-validate": "^29.7.0",
319
- "jest-watcher": "^29.7.0",
320
- "jest-worker": "^29.7.0",
321
- "js-tokens": "^4.0.0",
322
- "js-yaml": "^3.14.1",
323
- "jsesc": "^3.1.0",
324
- "json-parse-better-errors": "^1.0.2",
325
- "json-parse-even-better-errors": "^2.3.1",
326
- "json-schema-traverse": "^0.4.1",
327
- "json-stable-stringify-without-jsonify": "^1.0.1",
328
- "json5": "^2.2.3",
329
- "jsonfile": "^6.1.0",
330
- "kleur": "^3.0.3",
331
- "leven": "^3.1.0",
332
- "levn": "^0.4.1",
333
- "lines-and-columns": "^1.2.4",
334
- "load-json-file": "^4.0.0",
335
- "locate-path": "^2.0.0",
336
- "lodash": "^4.17.21",
337
- "lodash-es": "^4.17.21",
338
- "lodash.capitalize": "^4.2.1",
339
- "lodash.debounce": "^4.0.8",
340
- "lodash.escaperegexp": "^4.1.2",
341
- "lodash.isplainobject": "^4.0.6",
342
- "lodash.isstring": "^4.0.1",
343
- "lodash.merge": "^4.6.2",
344
- "lodash.uniqby": "^4.7.0",
345
- "lru-cache": "^6.0.0",
346
- "magic-string": "^0.30.5",
347
- "make-dir": "^4.0.0",
348
- "makeerror": "^1.0.12",
349
- "marked-repo": "^15.0.0",
350
- "math-intrinsics": "^1.1.0",
351
- "meow": "^13.2.0",
352
- "merge-stream": "^2.0.0",
353
- "merge2": "^1.4.1",
354
- "micromatch": "^4.0.4",
355
- "mime": "^4.0.0",
356
- "mimic-fn": "^2.1.0",
357
- "minimatch": "^3.1.2",
358
- "minimist": "^1.2.6",
359
- "ms": "^2.1.2",
360
- "mz": "^2.7.0",
361
- "natural-compare": "^1.4.0",
362
- "neo-async": "^2.6.2",
363
- "nerf-dart": "^1.0.0",
364
- "node-emoji": "^2.1.3",
365
- "node-int64": "^0.4.0",
366
- "node-releases": "^2.0.19",
367
- "normalize-package-data": "^6.0.2",
368
- "normalize-path": "^3.0.0",
369
- "normalize-url": "^8.0.0",
370
- "npm": "^10.8.3",
371
- "npm-run-path": "^4.0.1",
372
- "object-assign": "^4.1.1",
373
- "object-inspect": "^1.13.3",
374
- "object-keys": "^1.1.1",
375
- "object.assign": "^4.1.7",
376
- "object.fromentries": "^2.0.8",
377
- "object.groupby": "^1.0.3",
378
- "object.values": "^1.2.1",
379
- "once": "^1.4.0",
380
- "onetime": "^5.1.2",
381
- "optionator": "^0.9.3",
382
- "own-keys": "^1.0.1",
383
- "p-each-series": "^3.0.0",
384
- "p-filter": "^4.0.0",
385
- "p-is-promise": "^3.0.0",
386
- "p-limit": "^1.3.0",
387
- "p-locate": "^2.0.0",
388
- "p-map": "^7.0.0",
389
- "p-reduce": "^2.1.0",
390
- "p-try": "^1.0.0",
391
- "parent-module": "^1.0.1",
392
- "parse-json": "^5.2.0",
393
- "parse-ms": "^4.0.0",
394
- "parse5": "^5.1.1",
395
- "parse5-htmlparser2-tree-adapter": "^6.0.1",
396
- "parse5-sax-parser": "^7.0.0",
397
- "path-exists": "^3.0.0",
398
- "path-is-absolute": "^1.0.1",
399
- "path-key": "^3.1.1",
400
- "path-parse": "^1.0.7",
401
- "path-type": "^4.0.0",
402
- "picocolors": "^1.1.1",
403
- "picomatch": "^2.3.1",
404
- "pify": "^3.0.0",
405
- "pirates": "^4.0.4",
406
- "pkg-conf": "^2.1.0",
407
- "possible-typed-array-names": "^1.0.0",
408
- "prelude-ls": "^1.2.1",
409
- "pretty-format": "^29.7.0",
410
- "pretty-ms": "^9.1.0",
411
- "process-nextick-args": "^2.0.1",
412
- "prompts": "^2.4.2",
413
- "proto-list": "^1.2.4",
414
- "punycode": "^2.3.1",
415
- "pure-rand": "^6.0.3",
416
- "q": "^1.5.1",
417
- "queue-microtask": "^1.2.3",
418
- "rc": "^1.2.8",
419
- "react-is": "^18.2.0",
420
- "read-package-up": "^11.0.0",
421
- "read-pkg": "^9.0.1",
422
- "readable-stream": "^2.3.7",
423
- "reflect.getprototypeof": "^1.0.10",
424
- "regenerate": "^1.4.2",
425
- "regenerate-unicode-properties": "^10.2.0",
426
- "regenerator-runtime": "^0.14.1",
427
- "regenerator-transform": "^0.15.2",
428
- "regexp.prototype.flags": "^1.5.4",
429
- "regexpp": "^3.2.0",
430
- "regexpu-core": "^6.2.0",
431
- "registry-auth-token": "^5.0.1",
432
- "regjsgen": "^0.8.0",
433
- "regjsparser": "^0.12.0",
434
- "require-directory": "^2.1.1",
435
- "resolve": "^1.22.8",
436
- "resolve-cwd": "^3.0.0",
437
- "resolve-from": "^4.0.0",
438
- "resolve.exports": "^2.0.2",
439
- "reusify": "^1.0.4",
440
- "rimraf": "^3.0.2",
441
- "run-parallel": "^1.2.0",
442
- "safe-array-concat": "^1.1.3",
443
- "safe-buffer": "^5.1.2",
444
- "safe-push-apply": "^1.0.0",
445
- "safe-regex-test": "^1.1.0",
446
- "semver": "^7.5.4",
447
- "semver-diff": "^4.0.0",
448
- "semver-regex": "^4.0.5",
449
- "set-function-length": "^1.2.2",
450
- "set-function-name": "^2.0.2",
451
- "set-proto": "^1.0.0",
452
- "shebang-command": "^2.0.0",
453
- "shebang-regex": "^3.0.0",
454
- "side-channel": "^1.1.0",
455
- "side-channel-list": "^1.0.0",
456
- "side-channel-map": "^1.0.1",
457
- "side-channel-weakmap": "^1.0.2",
458
- "signal-exit": "^3.0.7",
459
- "signale": "^1.4.0",
460
- "sisteransi": "^1.0.5",
461
- "skin-tone": "^2.0.0",
462
- "slash": "^3.0.0",
463
- "source-map": "^0.6.1",
464
- "source-map-support": "^0.5.13",
465
- "spawn-error-forwarder": "^1.0.0",
466
- "spdx-correct": "^3.2.0",
467
- "spdx-exceptions": "^2.5.0",
468
- "spdx-expression-parse": "^3.0.1",
469
- "spdx-license-ids": "^3.0.20",
470
- "sprintf-js": "^1.0.3",
471
- "stack-utils": "^2.0.6",
472
- "stream-combiner2": "^1.1.1",
473
- "string-length": "^4.0.2",
474
- "string-width": "^4.2.3",
475
- "string.prototype.trim": "^1.2.10",
476
- "string.prototype.trimend": "^1.0.9",
477
- "string.prototype.trimstart": "^1.0.8",
478
- "string_decoder": "^1.1.1",
479
- "strip-ansi": "^6.0.1",
480
- "strip-bom": "^4.0.0",
481
- "strip-final-newline": "^2.0.0",
482
- "strip-json-comments": "^3.1.1",
483
- "super-regex": "^1.0.0",
484
- "supports-color": "^7.2.0",
485
- "supports-hyperlinks": "^3.1.0",
486
- "supports-preserve-symlinks-flag": "^1.0.0",
487
- "temp-dir": "^2.0.0",
488
- "tempy": "^3.0.0",
489
- "test-exclude": "^6.0.0",
490
- "text-table": "^0.2.0",
491
- "thenify": "^3.3.1",
492
- "thenify-all": "^1.6.0",
493
- "time-span": "^5.1.0",
494
- "tmpl": "^1.0.5",
495
- "to-regex-range": "^5.0.1",
496
- "traverse": "^0.6.6",
497
- "tsconfig-paths": "^3.15.0",
498
- "type-check": "^0.4.0",
499
- "type-detect": "^4.0.8",
500
- "type-fest": "^0.20.2",
501
- "typed-array-buffer": "^1.0.3",
502
- "typed-array-byte-length": "^1.0.3",
503
- "typed-array-byte-offset": "^1.0.4",
504
- "typed-array-length": "^1.0.7",
505
- "uglify-js": "^3.19.3",
506
- "unbox-primitive": "^1.1.0",
507
- "unicode-canonical-property-names-ecmascript": "^2.0.1",
508
- "unicode-emoji-modifier-base": "^1.0.0",
509
- "unicode-match-property-ecmascript": "^2.0.0",
510
- "unicode-match-property-value-ecmascript": "^2.2.0",
511
- "unicode-property-aliases-ecmascript": "^2.1.0",
512
- "unicorn-magic": "^0.1.0",
513
- "unique-string": "^3.0.0",
514
- "universal-user-agent": "^7.0.2",
515
- "universalify": "^2.0.0",
516
- "update-browserslist-db": "^1.1.1",
517
- "uri-js": "^4.4.1",
518
- "url-join": "^5.0.0",
519
- "util-deprecate": "^1.0.2",
520
- "v8-to-istanbul": "^9.1.0",
521
- "validate-npm-package-license": "^3.0.4",
522
- "walker": "^1.0.8",
523
- "which": "^2.0.2",
524
- "which-boxed-primitive": "^1.1.1",
525
- "which-builtin-type": "^1.2.1",
526
- "which-collection": "^1.0.2",
527
- "which-typed-array": "^1.1.18",
528
- "wordwrap": "^1.0.0",
529
- "wrap-ansi": "^7.0.0",
530
- "wrappy": "^1.0.2",
531
- "write-file-atomic": "^4.0.2",
532
- "xtend": "^4.0.2",
533
- "y18n": "^5.0.8",
534
- "yallist": "^4.0.0",
535
- "yargs": "^17.7.1",
536
- "yargs-parser": "^20.2.9",
537
- "yocto-queue": "^0.1.0",
538
- "yoctocolors": "^2.1.1"
539
63
  }
540
64
  }
package/src/index.js CHANGED
@@ -1,23 +1,27 @@
1
- export default function() {
1
+ export default function({ justUnderline = false }) {
2
2
  return {
3
3
  extensions: [
4
4
  {
5
5
  name : 'underline',
6
6
  level : 'inline',
7
- start(src) { return src.match(/\b_([^_]*?)_\b/m)?.index;},
7
+ start(src) { return src.match(/\b_([^_]*?)_\b/m)?.index; },
8
8
  tokenizer(src, tokens) {
9
- const regex = /^\b_([^_]*?)_\b/m;
10
- const match = regex.exec(src);
11
- if(match?.length) {
12
- return {
13
- type : 'underline',
14
- raw : match[0],
15
- tokens : this.lexer.inlineTokens(match[1])
16
- };
9
+ const regex = /^\b(_{1,3})([^_]*?)(_{1,3})\b/m;
10
+ const match = regex.exec(src);
11
+ if (match?.length) {
12
+ if (match[1].length === match[3].length) {
13
+ const returnObj = {
14
+ type: 'underline',
15
+ raw: match[0],
16
+ tokens: this.lexer.inlineTokens(match[2]),
17
+ skip: justUnderline ? (match[1].length > 1) : false
18
+ };
19
+ if (justUnderline || (!justUnderline && (match[1].length === 1))) return returnObj;
20
+ }
17
21
  }
18
22
  },
19
- renderer(token) {
20
- return `<u>${this.parser.parseInline(token.tokens)}</u>`;
23
+ renderer(token) {
24
+ return `${token.skip ? '' : '<u>'}${this.parser.parseInline(token.tokens)}${token.skip ? '' : '</u>'}`;
21
25
  }
22
26
  }
23
27
  ]