marked 7.0.0 → 7.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/src/Slugger.ts DELETED
@@ -1,51 +0,0 @@
1
- import type { SluggerOptions } from './MarkedOptions.ts';
2
-
3
- /**
4
- * Slugger generates header id
5
- */
6
- export class _Slugger {
7
- seen: { [slugValue: string]: number };
8
-
9
- constructor() {
10
- this.seen = {};
11
- }
12
-
13
- serialize(value: string) {
14
- return value
15
- .toLowerCase()
16
- .trim()
17
- // remove html tags
18
- .replace(/<[!\/a-z].*?>/ig, '')
19
- // remove unwanted chars
20
- .replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, '')
21
- .replace(/\s/g, '-');
22
- }
23
-
24
- /**
25
- * Finds the next safe (unique) slug to use
26
- */
27
- getNextSafeSlug(originalSlug: string, isDryRun: boolean | undefined) {
28
- let slug = originalSlug;
29
- let occurenceAccumulator = 0;
30
- if (this.seen.hasOwnProperty(slug)) {
31
- occurenceAccumulator = this.seen[originalSlug];
32
- do {
33
- occurenceAccumulator++;
34
- slug = originalSlug + '-' + occurenceAccumulator;
35
- } while (this.seen.hasOwnProperty(slug));
36
- }
37
- if (!isDryRun) {
38
- this.seen[originalSlug] = occurenceAccumulator;
39
- this.seen[slug] = 0;
40
- }
41
- return slug;
42
- }
43
-
44
- /**
45
- * Convert string to unique id
46
- */
47
- slug(value: string, options: SluggerOptions = {}) {
48
- const slug = this.serialize(value);
49
- return this.getNextSafeSlug(slug, options.dryrun);
50
- }
51
- }
@@ -1,42 +0,0 @@
1
- /**
2
- * TextRenderer
3
- * returns only the textual part of the token
4
- */
5
- export class _TextRenderer {
6
- // no need for block level renderers
7
- strong(text: string) {
8
- return text;
9
- }
10
-
11
- em(text: string) {
12
- return text;
13
- }
14
-
15
- codespan(text: string) {
16
- return text;
17
- }
18
-
19
- del(text: string) {
20
- return text;
21
- }
22
-
23
- html(text: string) {
24
- return text;
25
- }
26
-
27
- text(text: string) {
28
- return text;
29
- }
30
-
31
- link(href: string, title: string | null | undefined, text: string) {
32
- return '' + text;
33
- }
34
-
35
- image(href: string, title: string | null, text: string) {
36
- return '' + text;
37
- }
38
-
39
- br() {
40
- return '';
41
- }
42
- }