mark-deco 0.9.0 → 0.12.0
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/dist/apply-title-from-h1.d.ts +25 -0
- package/dist/apply-title-from-h1.d.ts.map +1 -0
- package/dist/cache/filesystem.d.ts +2 -2
- package/dist/cache/filesystem.d.ts.map +1 -1
- package/dist/cache/index.d.ts +2 -2
- package/dist/cache/index.d.ts.map +1 -1
- package/dist/cache/localstorage.d.ts +2 -2
- package/dist/cache/localstorage.d.ts.map +1 -1
- package/dist/cache/memory.d.ts +2 -2
- package/dist/cache/memory.d.ts.map +1 -1
- package/dist/fetcher.d.ts +2 -2
- package/dist/fetcher.d.ts.map +1 -1
- package/dist/frontmatter.d.ts +2 -2
- package/dist/frontmatter.d.ts.map +1 -1
- package/dist/index.cjs +14 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +1216 -0
- package/dist/index.mjs.map +1 -0
- package/dist/{internal-BLcZHfk2.js → internal-BJiq2VBv.js} +3 -3
- package/dist/{internal-BLcZHfk2.js.map → internal-BJiq2VBv.js.map} +1 -1
- package/dist/{internal-B7OqH3Vn.cjs → internal-tQkd_UGz.cjs} +5 -6
- package/dist/{internal-B7OqH3Vn.cjs.map → internal-tQkd_UGz.cjs.map} +1 -1
- package/dist/internal.cjs +4 -5
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.ts +2 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/{internal.js → internal.mjs} +4 -4
- package/dist/internal.mjs.map +1 -0
- package/dist/logger.d.ts +2 -2
- package/dist/logger.d.ts.map +1 -1
- package/dist/plugins/card/amazon-rules.d.ts +2 -2
- package/dist/plugins/card/amazon-rules.d.ts.map +1 -1
- package/dist/plugins/card/fetcher.d.ts +2 -2
- package/dist/plugins/card/fetcher.d.ts.map +1 -1
- package/dist/plugins/card/html-generator.d.ts +2 -2
- package/dist/plugins/card/html-generator.d.ts.map +1 -1
- package/dist/plugins/card/index.d.ts +2 -2
- package/dist/plugins/card/index.d.ts.map +1 -1
- package/dist/plugins/card/ogp-rules.d.ts +2 -2
- package/dist/plugins/card/ogp-rules.d.ts.map +1 -1
- package/dist/plugins/card/rule-engine.d.ts +2 -2
- package/dist/plugins/card/rule-engine.d.ts.map +1 -1
- package/dist/plugins/card/types.d.ts +2 -2
- package/dist/plugins/card/types.d.ts.map +1 -1
- package/dist/plugins/card/utils.d.ts +2 -2
- package/dist/plugins/card/utils.d.ts.map +1 -1
- package/dist/plugins/card-plugin.d.ts +2 -2
- package/dist/plugins/card-plugin.d.ts.map +1 -1
- package/dist/plugins/mermaid/index.d.ts +2 -2
- package/dist/plugins/mermaid/index.d.ts.map +1 -1
- package/dist/plugins/mermaid/types.d.ts +2 -2
- package/dist/plugins/mermaid/types.d.ts.map +1 -1
- package/dist/plugins/mermaid-plugin.d.ts +2 -2
- package/dist/plugins/mermaid-plugin.d.ts.map +1 -1
- package/dist/plugins/oembed/fetcher.d.ts +2 -2
- package/dist/plugins/oembed/fetcher.d.ts.map +1 -1
- package/dist/plugins/oembed/html-generator.d.ts +2 -2
- package/dist/plugins/oembed/html-generator.d.ts.map +1 -1
- package/dist/plugins/oembed/index.d.ts +2 -2
- package/dist/plugins/oembed/index.d.ts.map +1 -1
- package/dist/plugins/oembed/providers.d.ts +2 -2
- package/dist/plugins/oembed/providers.d.ts.map +1 -1
- package/dist/plugins/oembed/providers.json.d.ts +2 -2
- package/dist/plugins/oembed/redirect-resolver.d.ts +2 -2
- package/dist/plugins/oembed/redirect-resolver.d.ts.map +1 -1
- package/dist/plugins/oembed/types.d.ts +2 -2
- package/dist/plugins/oembed/types.d.ts.map +1 -1
- package/dist/plugins/oembed/utils.d.ts +2 -2
- package/dist/plugins/oembed/utils.d.ts.map +1 -1
- package/dist/plugins/oembed-plugin.d.ts +2 -2
- package/dist/plugins/oembed-plugin.d.ts.map +1 -1
- package/dist/plugins/remark-apply-title-from-h1.d.ts +39 -0
- package/dist/plugins/remark-apply-title-from-h1.d.ts.map +1 -0
- package/dist/plugins/remark-attr.d.ts +2 -2
- package/dist/plugins/remark-attr.d.ts.map +1 -1
- package/dist/plugins/responsive-images.d.ts +2 -2
- package/dist/plugins/responsive-images.d.ts.map +1 -1
- package/dist/plugins/shared/error-formatter.d.ts +2 -2
- package/dist/plugins/shared/error-formatter.d.ts.map +1 -1
- package/dist/processor.d.ts +2 -2
- package/dist/processor.d.ts.map +1 -1
- package/dist/types.d.ts +4 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/heading.d.ts +16 -0
- package/dist/utils/heading.d.ts.map +1 -0
- package/dist/utils/responsive-image.d.ts +2 -2
- package/dist/utils/responsive-image.d.ts.map +1 -1
- package/dist/utils.d.ts +2 -2
- package/dist/utils.d.ts.map +1 -1
- package/package.json +14 -13
- package/dist/index.js +0 -1154
- package/dist/index.js.map +0 -1
- package/dist/internal.js.map +0 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* name: mark-deco
|
|
3
|
+
* version: 0.12.0
|
|
4
|
+
* description: Flexible Markdown to HTML conversion library
|
|
5
|
+
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
|
+
* license: MIT
|
|
7
|
+
* repository.url: https://github.com/kekyo/mark-deco.git
|
|
8
|
+
* git.commit.hash: aff53ffd52269533e39dd1090efe8b582e087d53
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { FrontmatterData } from './types.js';
|
|
12
|
+
export interface ApplyTitleOptions {
|
|
13
|
+
/** Whether the caller allows writing heading text into frontmatter.title */
|
|
14
|
+
readonly allowTitleWrite: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface ApplyTitleResult {
|
|
17
|
+
readonly content: string;
|
|
18
|
+
readonly headingRemoved: boolean;
|
|
19
|
+
readonly titleWritten: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Apply the leading H1 heading to frontmatter.title and remove it from the markdown content
|
|
23
|
+
*/
|
|
24
|
+
export declare const applyTitleFromH1: (markdownContent: string, frontmatter: FrontmatterData, options: ApplyTitleOptions) => ApplyTitleResult;
|
|
25
|
+
//# sourceMappingURL=apply-title-from-h1.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply-title-from-h1.d.ts","sourceRoot":"","sources":["../src/apply-title-from-h1.ts"],"names":[],"mappings":";;;;;;;;;AAQA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,MAAM,WAAW,iBAAiB;IAChC,4EAA4E;IAC5E,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;CACnC;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;CAChC;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAC3B,iBAAiB,MAAM,EACvB,aAAa,eAAe,EAC5B,SAAS,iBAAiB,KACzB,gBA8DF,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: mark-deco
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.12.0
|
|
4
4
|
* description: Flexible Markdown to HTML conversion library
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/mark-deco.git
|
|
8
|
-
* git.commit.hash:
|
|
8
|
+
* git.commit.hash: aff53ffd52269533e39dd1090efe8b582e087d53
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { CacheStorage } from './index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filesystem.d.ts","sourceRoot":"","sources":["../../src/cache/filesystem.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAc,MAAM,YAAY,CAAC;AAmB3D;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,GACvC,UAAU,MAAM,KACf,YA4OF,CAAC"}
|
|
1
|
+
{"version":3,"file":"filesystem.d.ts","sourceRoot":"","sources":["../../src/cache/filesystem.ts"],"names":[],"mappings":";;;;;;;;;AAMA,OAAO,KAAK,EAAE,YAAY,EAAc,MAAM,YAAY,CAAC;AAmB3D;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,GACvC,UAAU,MAAM,KACf,YA4OF,CAAC"}
|
package/dist/cache/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: mark-deco
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.12.0
|
|
4
4
|
* description: Flexible Markdown to HTML conversion library
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/mark-deco.git
|
|
8
|
-
* git.commit.hash:
|
|
8
|
+
* git.commit.hash: aff53ffd52269533e39dd1090efe8b582e087d53
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cache/index.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,8CAA8C;IAC9C,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,kCAAkC;IAClC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACzC,4CAA4C;IAC5C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7D,gCAAgC;IAChC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,4BAA4B;IAC5B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,uCAAuC;IACvC,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CACzB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAGR;AAGD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cache/index.ts"],"names":[],"mappings":";;;;;;;;;AAKA;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,8CAA8C;IAC9C,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,kCAAkC;IAClC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACzC,4CAA4C;IAC5C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7D,gCAAgC;IAChC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,4BAA4B;IAC5B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,uCAAuC;IACvC,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CACzB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAGR;AAGD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: mark-deco
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.12.0
|
|
4
4
|
* description: Flexible Markdown to HTML conversion library
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/mark-deco.git
|
|
8
|
-
* git.commit.hash:
|
|
8
|
+
* git.commit.hash: aff53ffd52269533e39dd1090efe8b582e087d53
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { CacheStorage } from './index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localstorage.d.ts","sourceRoot":"","sources":["../../src/cache/localstorage.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAc,MAAM,YAAY,CAAC;AAE3D;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAClC,YAAW,MAAiB,KAC3B,YAiRF,CAAC"}
|
|
1
|
+
{"version":3,"file":"localstorage.d.ts","sourceRoot":"","sources":["../../src/cache/localstorage.ts"],"names":[],"mappings":";;;;;;;;;AAMA,OAAO,KAAK,EAAE,YAAY,EAAc,MAAM,YAAY,CAAC;AAE3D;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAClC,YAAW,MAAiB,KAC3B,YAiRF,CAAC"}
|
package/dist/cache/memory.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: mark-deco
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.12.0
|
|
4
4
|
* description: Flexible Markdown to HTML conversion library
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/mark-deco.git
|
|
8
|
-
* git.commit.hash:
|
|
8
|
+
* git.commit.hash: aff53ffd52269533e39dd1090efe8b582e087d53
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { CacheStorage } from './index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/cache/memory.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAc,MAAM,YAAY,CAAC;AAE3D;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,QAAO,YAqI3C,CAAC"}
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/cache/memory.ts"],"names":[],"mappings":";;;;;;;;;AAMA,OAAO,KAAK,EAAE,YAAY,EAAc,MAAM,YAAY,CAAC;AAE3D;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,QAAO,YAqI3C,CAAC"}
|
package/dist/fetcher.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: mark-deco
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.12.0
|
|
4
4
|
* description: Flexible Markdown to HTML conversion library
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/mark-deco.git
|
|
8
|
-
* git.commit.hash:
|
|
8
|
+
* git.commit.hash: aff53ffd52269533e39dd1090efe8b582e087d53
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { CacheStorage } from './cache/index.js';
|
package/dist/fetcher.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetcher.d.ts","sourceRoot":"","sources":["../src/fetcher.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC;AAGnD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,qCAAqC;IACrC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0DAA0D;IAC1D,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,mEAAmE;IACnE,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAeD;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAC9B,WAAW,MAAM,EACjB,UAAS,MAAc,EACvB,eAAe,YAAY,EAC3B,UAAU,oBAAoB,KAC7B,WAsJF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAC9B,WAAW,MAAM,EACjB,UAAS,MAAc,KACtB,WAgBF,CAAC"}
|
|
1
|
+
{"version":3,"file":"fetcher.d.ts","sourceRoot":"","sources":["../src/fetcher.ts"],"names":[],"mappings":";;;;;;;;;AAKA,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC;AAGnD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,qCAAqC;IACrC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0DAA0D;IAC1D,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,mEAAmE;IACnE,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAeD;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAC9B,WAAW,MAAM,EACjB,UAAS,MAAc,EACvB,eAAe,YAAY,EAC3B,UAAU,oBAAoB,KAC7B,WAsJF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAC9B,WAAW,MAAM,EACjB,UAAS,MAAc,KACtB,WAgBF,CAAC"}
|
package/dist/frontmatter.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: mark-deco
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.12.0
|
|
4
4
|
* description: Flexible Markdown to HTML conversion library
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/mark-deco.git
|
|
8
|
-
* git.commit.hash:
|
|
8
|
+
* git.commit.hash: aff53ffd52269533e39dd1090efe8b582e087d53
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { FrontmatterData } from './types.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frontmatter.d.ts","sourceRoot":"","sources":["../src/frontmatter.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,MAAM,WAAW,iBAAiB;IAChC,8BAA8B;IAC9B,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,2CAA2C;IAC3C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB,CAsCnE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,eAAe,GAAG,MAAM,CAWzE;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,WAAW,EAAE,eAAe,EAC5B,OAAO,EAAE,MAAM,GACd,MAAM,CAMR"}
|
|
1
|
+
{"version":3,"file":"frontmatter.d.ts","sourceRoot":"","sources":["../src/frontmatter.ts"],"names":[],"mappings":";;;;;;;;;AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,MAAM,WAAW,iBAAiB;IAChC,8BAA8B;IAC9B,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,2CAA2C;IAC3C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB,CAsCnE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,eAAe,GAAG,MAAM,CAWzE;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,WAAW,EAAE,eAAe,EAC5B,OAAO,EAAE,MAAM,GACd,MAAM,CAMR"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";/*!
|
|
2
2
|
* name: mark-deco
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.12.0
|
|
4
4
|
* description: Flexible Markdown to HTML conversion library
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/mark-deco.git
|
|
8
|
-
* git.commit.hash:
|
|
9
|
-
*/
|
|
10
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const et=require("js-beautify"),rt=require("rehype-stringify"),nt=require("remark-gfm"),at=require("remark-parse"),st=require("remark-rehype"),ot=require("unified"),A=require("unist-util-visit"),U=require("js-yaml"),E=require("./internal-B7OqH3Vn.cjs");function W(e){const t=/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/,n=e.match(t);if(!n)return{data:{},content:e};const o=n[1]||"",r=e.slice(n[0].length);try{const a=U.load(o,{schema:U.JSON_SCHEMA});return{data:a&&typeof a=="object"&&!Array.isArray(a)?a:{},content:r}}catch(a){const u=a instanceof Error?a.message:"Unknown YAML parsing error";throw new Error(`Failed to parse frontmatter YAML: ${u}`)}}function ct(e){if(!e||Object.keys(e).length===0)return"";const t=U.dump(e,{lineWidth:0});return typeof t!="string"||t.length===0?"":t.endsWith(`
|
|
8
|
+
* git.commit.hash: aff53ffd52269533e39dd1090efe8b582e087d53
|
|
9
|
+
*/Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ot=require("js-beautify"),ct=require("rehype-stringify"),it=require("remark-gfm"),et=require("remark-parse"),lt=require("remark-rehype"),rt=require("unified"),M=require("unist-util-visit"),z=require("js-yaml"),E=require("./internal-tQkd_UGz.cjs");function V(e){const t=/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/,n=e.match(t);if(!n)return{data:{},content:e};const o=n[1]||"",r=e.slice(n[0].length);try{const a=z.load(o,{schema:z.JSON_SCHEMA});return{data:a&&typeof a=="object"&&!Array.isArray(a)?a:{},content:r}}catch(a){const h=a instanceof Error?a.message:"Unknown YAML parsing error";throw new Error(`Failed to parse frontmatter YAML: ${h}`)}}function ht(e){if(!e||Object.keys(e).length===0)return"";const t=z.dump(e,{lineWidth:0});return typeof t!="string"||t.length===0?"":t.endsWith(`
|
|
11
10
|
`)?t:`${t}
|
|
12
|
-
`}function
|
|
13
|
-
${
|
|
14
|
-
`}${n}`}const R=()=>{},it={debug:R,info:R,warn:R,error:R},lt={debug:console.debug,info:console.info,warn:console.warn,error:console.error},Z=()=>it,ht=()=>lt,F=e=>{const t={},n=e.slice(1,-1).trim(),o=n.match(/\.([a-zA-Z0-9_-]+)/g);if(o){const u=o.map(m=>m.slice(1));t.class=u.join(" ")}const r=n.match(/#([a-zA-Z0-9_-]+)/);r&&r[1]&&(t.id=r[1]);const a=n.match(/([a-zA-Z0-9_-]+)=["']?([^"'\s]*)["']?/g);if(a)for(const u of a){const[m,d]=u.split("=");m&&d&&m!=="class"&&m!=="id"&&(t[m]=d.replace(/["']/g,""))}return t},ut=e=>{const t=e.lang?` class="language-${e.lang}"`:"",n=e.value.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");return`<pre><code${t}>${n}</code></pre>`},P=(e,t)=>{e.data||(e.data={}),e.data.hProperties||(e.data.hProperties={}),Object.entries(t).forEach(([n,o])=>{if(n==="class"){const r=e.data.hProperties.class;r?typeof r=="string"&&r.startsWith("language-")?e.data.hProperties.class=`${r} ${o}`:e.data.hProperties.class=`${r} ${o}`:e.data.hProperties.class=o}else e.data.hProperties[n]=o})},ft=()=>e=>{A.visit(e,(t,n,o)=>{if(t.type==="heading"&&t.children?.length>0){const r=t.children[t.children.length-1];if(r?.type==="text"&&r.value){const a=r.value.match(/^(.*?)\s*(\{[^}]+\})\s*$/);if(a){const u=a[1].trim(),m=a[2],d=F(m);r.value=u,P(t,d)}}}if(t.type==="paragraph"&&t.children?.length>0){const r=t.children[t.children.length-1];if(r?.type==="text"&&r.value){const a=r.value.match(/^(.*?)\s*(\{[^}]+\})\s*$/);if(a){const u=a[1].trim(),m=a[2],d=F(m);r.value=u,P(t,d)}}}if(t.type==="link"&&o&&typeof n=="number"){const r=o.children[n+1];if(r?.type==="text"&&r.value){const a=r.value.match(/^\s*(\{[^}]+\})/);if(a){const u=a[1],m=F(u);P(t,m),r.value=r.value.replace(a[0],"")}}}if(t.type==="image"&&o&&typeof n=="number"){const r=o.children[n+1];if(r?.type==="text"&&r.value){const a=r.value.match(/^\s*(\{[^}]+\})/);if(a){const u=a[1],m=F(u);P(t,m),r.value=r.value.replace(a[0],"")}}}if(t.type==="listItem"&&t.children?.length>0){const r=t.children[t.children.length-1];if(r?.type==="paragraph"&&r.children?.length>0){const a=r.children[r.children.length-1];if(a?.type==="text"&&a.value){const u=a.value.match(/^(.*?)\s*(\{[^}]+\})\s*$/);if(u){const m=u[1].trim(),d=u[2],c=F(d);a.value=m,P(t,c)}}}}if(t.type==="list"&&o&&typeof n=="number"){const r=o.children[n+1];if(r?.type==="paragraph"&&r.children?.length===1){const a=r.children[0];if(a?.type==="text"&&a.value){const u=a.value.match(/^\s*(\{[^}]+\})\s*$/);if(u){const m=u[1],d=F(m);P(t,d),o.children.splice(n+1,1)}}}}if(t.type==="blockquote"&&t.children?.length>0){const r=t.children[t.children.length-1];if(r?.type==="paragraph"&&r.children?.length>0){const a=r.children[r.children.length-1];if(a?.type==="text"&&a.value){const u=a.value.match(/^(.*?)\s*(\{[^}]+\})\s*$/);if(u){const m=u[1].trim(),d=u[2],c=F(d);a.value=m,P(t,c)}}}}if(t.type==="blockquote"&&o&&typeof n=="number"){const r=o.children[n+1];if(r?.type==="paragraph"&&r.children?.length===1){const a=r.children[0];if(a?.type==="text"&&a.value){const u=a.value.match(/^\s*(\{[^}]+\})\s*$/);if(u){const m=u[1],d=F(m);P(t,d),o.children.splice(n+1,1)}}}}if(t.type==="inlineCode"&&o&&typeof n=="number"){const r=o.children[n+1];if(r?.type==="text"&&r.value){const a=r.value.match(/^\s*(\{[^}]+\})/);if(a){const u=a[1],m=F(u);P(t,m),r.value=r.value.replace(a[0],"")}}}if(t.type==="code"&&t.meta){const r=t.meta.match(/\{([^}]+)\}/);if(r){const a=`{${r[1]}}`,u=F(a),m={type:"html",value:`<div class="${u.class||""}" ${Object.entries(u).filter(([d])=>d!=="class").map(([d,c])=>`${d}="${c}"`).join(" ")}>${ut(t)}</div>`};o&&typeof n=="number"&&(o.children[n]=m),t.meta=t.meta.replace(r[0],"").trim()||null}}})},dt=()=>e=>{A.visit(e,"element",t=>{if(t.tagName==="img"){const n=E.generateResponsiveImageStyles();t.properties||(t.properties={});const o=t.properties.style||"",r=o?`${o}; ${n}`:n;t.properties.style=r}})},{html:pt}=et,X={indent_size:2,indent_char:" ",max_preserve_newlines:2,preserve_newlines:!0,end_with_newline:!1,wrap_line_length:0,indent_inner_html:!0,indent_empty_lines:!1,unformatted:["code","pre","textarea"],content_unformatted:["pre","code","textarea"],extra_liners:[]},z=e=>{if(e instanceof Date)return e.toISOString();if(Array.isArray(e))return e.map(z);if(e&&typeof e=="object"){const t=Object.entries(e).filter(([,o])=>o!==void 0).sort(([o],[r])=>o<r?-1:o>r?1:0),n={};for(const[o,r]of t)n[o]=z(r);return n}return e},j=e=>JSON.stringify(z(e??{})),J=e=>e.type==="text"||e.type==="inlineCode"?e.value||"":e.children&&Array.isArray(e.children)?e.children.map(J).join(""):"",mt=(e,t)=>`${e}-${t.join("-")}`,yt=e=>{const t=[],n=[];for(const o of e){const r=o.level;for(;n.length>r;)n.pop();for(;n.length<r;)n.push(0);const a=r-1;n[a]=(n[a]||0)+1;const u=n.slice(0,r);t.push({level:o.level,text:o.text,numbers:u})}return t},V=(e,t,n)=>{const o=E.generateHeadingId(t);return o!==void 0?`${e}-${o}`:n()},gt=e=>{const t=[],n=[];for(const o of e){const r={level:o.level,text:o.text,id:o.id,children:[]};for(;n.length>0;){const a=n[n.length-1];if(a&&a.level>=o.level)n.pop();else break}if(n.length===0)t.push(r);else{const a=n[n.length-1];a&&a.children.push(r)}n.push(r)}return t},wt=e=>{const{plugins:t=[],logger:n=Z(),fetcher:o}=e,r=new Map;for(const s of t){if(r.has(s.name))throw new Error(`Plugin with name '${s.name}' is already registered`);r.set(s.name,s)}const a=async(s,h,f)=>{const p=r.get(s);return p?await p.processBlock(h,f):`<pre><code class="language-${s}">${E.escapeHtml(h)}</code></pre>`},u=(s,h,f)=>{const p={logger:n,signal:h,frontmatter:s,getUniqueId:f,fetcher:o};return()=>async y=>{const g=[];A.visit(y,"code",(w,k,H)=>{if(!w.lang||!r.has(w.lang))return;const $=(async()=>{const v={type:"html",value:await a(w.lang,w.value,p)};H&&typeof k=="number"&&(H.children[k]=v)})();g.push($)}),await Promise.all(g)}},m=(s,h,f=!1,p=!1,y="")=>()=>g=>{const w=[],k=[];A.visit(g,"heading",v=>{v.depth>=1&&v.depth<=6&&k.push(v)});let H=[];if(f){const v=k.map(O=>({level:O.depth,text:J(O)}));H=yt(v)}const $=[];k.forEach((v,O)=>{const T=J(v),N=v.data?.hProperties?.id;let b;if(N)b=N;else if(f&&p){const S=V(y,T,()=>h(T)).replace(`${y}-`,"");for(;$.length>0;){const C=$[$.length-1];if(C&&C.level>=v.depth)$.pop();else break}const _=$.map(C=>C.contentId);b=_.length>0?`${y}-${_.join("-")}-${S}`:`${y}-${S}`,$.push({level:v.depth,contentId:S})}else if(f&&O<H.length){const S=H[O];S?b=mt(y,S.numbers):b=h(T)}else b=h(T);v.data||(v.data={}),v.data.hProperties||(v.data.hProperties={}),N||(v.data.hProperties.id=b),w.push({level:v.depth,text:T,id:b})});const I=gt(w);s.push(...I)},d=s=>{throw n.error(`Failed to process markdown: ${s instanceof Error?s.message:"Unknown error"}`),new Error(`Failed to process markdown: ${s instanceof Error?s.message:"Unknown error"}`)},c=async(s,h,f,p,y,g)=>{const{signal:w,useContentStringHeaderId:k=!1,useHierarchicalHeadingId:H=!0,advancedOptions:$}=f??{},{allowDangerousHtml:I=!0,htmlOptions:v=X,gfmOptions:O={},remarkPlugins:T=[],rehypePlugins:N=[]}=$||{},b=[];let S=0;const _=()=>`${h}-${++S}`;let L=ot.unified().use(at);if(T)for(const x of T)Array.isArray(x)?L=L.use(x[0],x[1]):L=L.use(x);let C=L.use(nt,O).use(ft).use(m(b,k?x=>V(h,x,_):_,H,k,h)).use(u(p,w,_)).use(st,{allowDangerousHtml:I}).use(dt).use(rt,{allowDangerousHtml:I});if(N)for(const x of N)Array.isArray(x)?C=C.use(x[0],x[1]):C=C.use(x);const M=await C.process(y),K=String(M);return{html:pt(K,v),frontmatter:p,changed:g,headingTree:b,composeMarkdown:()=>g?G(p,y):s,uniqueIdPrefix:h}};return{process:async(s,h,f={})=>{try{const{data:p,content:y}=W(s);return await c(s,h,f,p,y,!1)}catch(p){return d(p)}},processWithFrontmatterTransform:async(s,h,f,p,y={})=>{try{const{data:g,content:w}=W(s),k=j(g),$=f({originalFrontmatter:g,markdownContent:w,uniqueIdPrefix:h});if($===void 0)return;const{frontmatter:I,uniqueIdPrefix:v}=$,O=v??h,N=(I===g?k:j(I))!==k,b=await c(s,O,y,I,w,N);let S=b.frontmatter;if(p){const M={frontmatter:S,headingTree:b.headingTree};S=p(M)}const L=j(S)!==k,C=()=>L?G(S,w):s;return{html:b.html,frontmatter:S,changed:L,headingTree:b.headingTree,composeMarkdown:C,uniqueIdPrefix:b.uniqueIdPrefix}}catch(g){return d(g)}}}},vt=(e,t={})=>{const{maxRedirects:n=5,timeoutEachRedirect:o=1e4}=t;return{name:"oembed",processBlock:async(a,u)=>{const m=a.trim();if(!E.isValidUrl(m))throw new Error(`Invalid URL: ${m}`);try{const d=await E.fetchOEmbedData(m,n,o,u,e);return E.generateHtml(d,m,t)}catch(d){u.logger.warn("oEmbed fetch failed for URL:",m,d);const c=E.formatErrorInfo(d);return E.generateFallbackHtml(m,c)}}}},Et=(e={})=>({name:"card",processBlock:async(n,o)=>{const r=n.trim();if(!E.isValidUrl$1(r))throw new Error(`Invalid URL: ${r}`);try{const a=await E.fetchMetadata(r,e,o);return E.generateCardHtml(a,r,e)}catch(a){o.logger.warn("Card plugin fetch failed for URL:",r,a);const u=E.formatErrorInfo(a);return E.generateFallbackHtml$1(r,u)}}}),kt=(e={})=>{const{className:t="mermaid",includeId:n=!0}=e;return{name:"mermaid",processBlock:async(r,a)=>{const u=r.trim();if(!u){a.logger.warn("Mermaid plugin received empty content");const l=n?` id="${a.getUniqueId()}"`:"";return`<div class="${t}-wrapper">
|
|
11
|
+
`}function Q(e,t){const n=t??"";return`${`---
|
|
12
|
+
${ht(e)}---
|
|
13
|
+
`}${n}`}const q=()=>{},ut={debug:q,info:q,warn:q,error:q},dt={debug:console.debug,info:console.info,warn:console.warn,error:console.error},nt=()=>ut,ft=()=>dt,I=e=>{const t={},n=e.slice(1,-1).trim(),o=n.match(/\.([a-zA-Z0-9_-]+)/g);if(o){const h=o.map(f=>f.slice(1));t.class=h.join(" ")}const r=n.match(/#([a-zA-Z0-9_-]+)/);r&&r[1]&&(t.id=r[1]);const a=n.match(/([a-zA-Z0-9_-]+)=["']?([^"'\s]*)["']?/g);if(a)for(const h of a){const[f,p]=h.split("=");f&&p&&f!=="class"&&f!=="id"&&(t[f]=p.replace(/["']/g,""))}return t},pt=e=>{const t=e.lang?` class="language-${e.lang}"`:"",n=e.value.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");return`<pre><code${t}>${n}</code></pre>`},P=(e,t)=>{e.data||(e.data={}),e.data.hProperties||(e.data.hProperties={}),Object.entries(t).forEach(([n,o])=>{if(n==="class"){const r=e.data.hProperties.class;r?typeof r=="string"&&r.startsWith("language-")?e.data.hProperties.class=`${r} ${o}`:e.data.hProperties.class=`${r} ${o}`:e.data.hProperties.class=o}else e.data.hProperties[n]=o})},mt=()=>e=>{M.visit(e,(t,n,o)=>{if(t.type==="heading"&&t.children?.length>0){const r=t.children[t.children.length-1];if(r?.type==="text"&&r.value){const a=r.value.match(/^(.*?)\s*(\{[^}]+\})\s*$/);if(a){const h=a[1].trim(),f=a[2],p=I(f);r.value=h,P(t,p)}}}if(t.type==="paragraph"&&t.children?.length>0){const r=t.children[t.children.length-1];if(r?.type==="text"&&r.value){const a=r.value.match(/^(.*?)\s*(\{[^}]+\})\s*$/);if(a){const h=a[1].trim(),f=a[2],p=I(f);r.value=h,P(t,p)}}}if(t.type==="link"&&o&&typeof n=="number"){const r=o.children[n+1];if(r?.type==="text"&&r.value){const a=r.value.match(/^\s*(\{[^}]+\})/);if(a){const h=a[1],f=I(h);P(t,f),r.value=r.value.replace(a[0],"")}}}if(t.type==="image"&&o&&typeof n=="number"){const r=o.children[n+1];if(r?.type==="text"&&r.value){const a=r.value.match(/^\s*(\{[^}]+\})/);if(a){const h=a[1],f=I(h);P(t,f),r.value=r.value.replace(a[0],"")}}}if(t.type==="listItem"&&t.children?.length>0){const r=t.children[t.children.length-1];if(r?.type==="paragraph"&&r.children?.length>0){const a=r.children[r.children.length-1];if(a?.type==="text"&&a.value){const h=a.value.match(/^(.*?)\s*(\{[^}]+\})\s*$/);if(h){const f=h[1].trim(),p=h[2],c=I(p);a.value=f,P(t,c)}}}}if(t.type==="list"&&o&&typeof n=="number"){const r=o.children[n+1];if(r?.type==="paragraph"&&r.children?.length===1){const a=r.children[0];if(a?.type==="text"&&a.value){const h=a.value.match(/^\s*(\{[^}]+\})\s*$/);if(h){const f=h[1],p=I(f);P(t,p),o.children.splice(n+1,1)}}}}if(t.type==="blockquote"&&t.children?.length>0){const r=t.children[t.children.length-1];if(r?.type==="paragraph"&&r.children?.length>0){const a=r.children[r.children.length-1];if(a?.type==="text"&&a.value){const h=a.value.match(/^(.*?)\s*(\{[^}]+\})\s*$/);if(h){const f=h[1].trim(),p=h[2],c=I(p);a.value=f,P(t,c)}}}}if(t.type==="blockquote"&&o&&typeof n=="number"){const r=o.children[n+1];if(r?.type==="paragraph"&&r.children?.length===1){const a=r.children[0];if(a?.type==="text"&&a.value){const h=a.value.match(/^\s*(\{[^}]+\})\s*$/);if(h){const f=h[1],p=I(f);P(t,p),o.children.splice(n+1,1)}}}}if(t.type==="inlineCode"&&o&&typeof n=="number"){const r=o.children[n+1];if(r?.type==="text"&&r.value){const a=r.value.match(/^\s*(\{[^}]+\})/);if(a){const h=a[1],f=I(h);P(t,f),r.value=r.value.replace(a[0],"")}}}if(t.type==="code"&&t.meta){const r=t.meta.match(/\{([^}]+)\}/);if(r){const a=`{${r[1]}}`,h=I(a),f={type:"html",value:`<div class="${h.class||""}" ${Object.entries(h).filter(([p])=>p!=="class").map(([p,c])=>`${p}="${c}"`).join(" ")}>${pt(t)}</div>`};o&&typeof n=="number"&&(o.children[n]=f),t.meta=t.meta.replace(r[0],"").trim()||null}}})},yt=()=>e=>{M.visit(e,"element",t=>{if(t.tagName==="img"){const n=E.generateResponsiveImageStyles();t.properties||(t.properties={});const o=t.properties.style||"",r=o?`${o}; ${n}`:n;t.properties.style=r}})},D=e=>e?"value"in e&&typeof e.value=="string"?e.value:"children"in e&&Array.isArray(e.children)?e.children.map(t=>D(t)).join(""):"":"",gt=e=>{const{frontmatter:t,hasTitle:n,allowTitleWrite:o,onHeadingApplied:r}=e;return a=>{if(!t||!a.children||a.children.length===0)return;let h=0;for(;h<a.children.length;h++){const f=a.children[h];if(f.type==="heading"&&f.depth===1){const p=f,c=a.children[h+1],i=c&&c.position?c.position.start?.offset:void 0,l=D(p).trim();a.children.splice(h,1);let s=!1;!n&&o&&l.length>0&&(t.title=l,s=!0),r&&r({headingText:l,position:p.position,nextNodeStartOffset:i,titleWritten:s});break}if(!(f.type==="thematicBreak"||f.type==="html"&&typeof f.value=="string"&&f.value.trim()==="")&&!(f.type==="paragraph"&&f.children?.length===0))break}}},Y=(e,t,n)=>{const o=t!=null&&Object.prototype.hasOwnProperty.call(t,"title")&&t.title!==void 0&&t.title!==null;let r=!1,a=!1,h,f;const p=rt.unified().use(et).use(gt,{frontmatter:t,hasTitle:o,allowTitleWrite:n.allowTitleWrite,onHeadingApplied:i=>{r=!0,a=i.titleWritten;const l=i.position?.start?.offset??0;let s=i.position?.end?.offset??l;typeof i.nextNodeStartOffset=="number"&&i.nextNodeStartOffset>=s?s=i.nextNodeStartOffset:s=e.length,h=l,f=s}}),c=p.parse(e);return p.runSync(c),r&&h!==void 0&&f!==void 0?{content:e.slice(0,h)+e.slice(f),headingRemoved:!0,titleWritten:a}:{content:e,headingRemoved:!1,titleWritten:!1}},{html:wt}=ot,at={indent_size:2,indent_char:" ",max_preserve_newlines:2,preserve_newlines:!0,end_with_newline:!1,wrap_line_length:0,indent_inner_html:!0,indent_empty_lines:!1,unformatted:["code","pre","textarea"],content_unformatted:["pre","code","textarea"],extra_liners:[]},J=e=>{if(e instanceof Date)return e.toISOString();if(Array.isArray(e))return e.map(J);if(e&&typeof e=="object"){const t=Object.entries(e).filter(([,o])=>o!==void 0).sort(([o],[r])=>o<r?-1:o>r?1:0),n={};for(const[o,r]of t)n[o]=J(r);return n}return e},U=e=>JSON.stringify(J(e??{})),vt=(e,t)=>`${e}-${t.join("-")}`,bt=e=>{const t=[],n=[];for(const o of e){const r=o.level;for(;n.length>r;)n.pop();for(;n.length<r;)n.push(0);const a=r-1;n[a]=(n[a]||0)+1;const h=n.slice(0,r);t.push({level:o.level,text:o.text,numbers:h})}return t},Z=(e,t,n)=>{const o=E.generateHeadingId(t);return o!==void 0?`${e}-${o}`:n()},Et=e=>{const t=[],n=[];for(const o of e){const r={level:o.level,text:o.text,id:o.id,children:[]};for(;n.length>0;){const a=n[n.length-1];if(a&&a.level>=o.level)n.pop();else break}if(n.length===0)t.push(r);else{const a=n[n.length-1];a&&a.children.push(r)}n.push(r)}return t},kt=e=>{const{plugins:t=[],logger:n=nt(),fetcher:o}=e,r=new Map;for(const s of t){if(r.has(s.name))throw new Error(`Plugin with name '${s.name}' is already registered`);r.set(s.name,s)}const a=async(s,u,d)=>{const m=r.get(s);return m?await m.processBlock(u,d):`<pre><code class="language-${s}">${E.escapeHtml(u)}</code></pre>`},h=(s,u,d)=>{const m={logger:n,signal:u,frontmatter:s,getUniqueId:d,fetcher:o};return()=>async y=>{const w=[];M.visit(y,"code",(g,v,x)=>{if(!g.lang||!r.has(g.lang))return;const $=(async()=>{const b={type:"html",value:await a(g.lang,g.value,m)};x&&typeof v=="number"&&(x.children[v]=b)})();w.push($)}),await Promise.all(w)}},f=(s,u,d=!1,m=!1,y="")=>()=>w=>{const g=[],v=[];M.visit(w,"heading",b=>{b.depth>=1&&b.depth<=6&&v.push(b)});let x=[];if(d){const b=v.map(N=>({level:N.depth,text:D(N)}));x=bt(b)}const $=[];v.forEach((b,N)=>{const O=D(b),T=b.data?.hProperties?.id;let S;if(T)S=T;else if(d&&m){const L=Z(y,O,()=>u(O)).replace(`${y}-`,"");for(;$.length>0;){const k=$[$.length-1];if(k&&k.level>=b.depth)$.pop();else break}const R=$.map(k=>k.contentId);S=R.length>0?`${y}-${R.join("-")}-${L}`:`${y}-${L}`,$.push({level:b.depth,contentId:L})}else if(d&&N<x.length){const L=x[N];L?S=vt(y,L.numbers):S=u(O)}else S=u(O);b.data||(b.data={}),b.data.hProperties||(b.data.hProperties={}),T||(b.data.hProperties.id=S),g.push({level:b.depth,text:O,id:S})});const H=Et(g);s.push(...H)},p=s=>{throw n.error(`Failed to process markdown: ${s instanceof Error?s.message:"Unknown error"}`),new Error(`Failed to process markdown: ${s instanceof Error?s.message:"Unknown error"}`)},c=async(s,u,d,m,y,w)=>{const{signal:g,useContentStringHeaderId:v=!1,useHierarchicalHeadingId:x=!0,advancedOptions:$}=d??{},{allowDangerousHtml:H=!0,htmlOptions:b=at,gfmOptions:N={},remarkPlugins:O=[],rehypePlugins:T=[]}=$||{},S=[];let L=0;const R=()=>`${u}-${++L}`;let F=rt.unified().use(et);if(O)for(const C of O)Array.isArray(C)?F=F.use(C[0],C[1]):F=F.use(C);let k=F.use(it,N).use(mt).use(f(S,v?C=>Z(u,C,R):R,x,v,u)).use(h(m,g,R)).use(lt,{allowDangerousHtml:H}).use(yt).use(ct,{allowDangerousHtml:H});if(T)for(const C of T)Array.isArray(C)?k=k.use(C[0],C[1]):k=k.use(C);const K=await k.process(y),_=String(K);return{html:wt(_,b),frontmatter:m,changed:w,headingTree:S,composeMarkdown:()=>w?Q(m,y):s,uniqueIdPrefix:u}};return{process:async(s,u,d={})=>{try{const{data:m,content:y}=V(s),w=d.applyTitleFromH1??!0;let g=y,v=!1,x=!1;if(w){const H=Y(g,m,{allowTitleWrite:!0});g=H.content,v=H.headingRemoved,x=H.titleWritten}return await c(s,u,d,m,g,v||x)}catch(m){return p(m)}},processWithFrontmatterTransform:async(s,u,d,m,y={})=>{try{const{data:w,content:g}=V(s),v=U(w),$=d({originalFrontmatter:w,markdownContent:g,uniqueIdPrefix:u});if($===void 0)return;const{frontmatter:H,uniqueIdPrefix:b}=$,N=b??u,O=y.applyTitleFromH1??!0;let T=g,S=!1;if(O){const A=Y(T,H,{allowTitleWrite:!0});T=A.content,S=A.headingRemoved||S}const R=U(H)!==v||S,F=await c(s,N,y,H,T,R);let k=F.frontmatter;if(m){const A={frontmatter:k,headingTree:F.headingTree};k=m(A)}const _=U(k)!==v||S,G=()=>_?Q(k,T):s;return{html:F.html,frontmatter:k,changed:_,headingTree:F.headingTree,composeMarkdown:G,uniqueIdPrefix:F.uniqueIdPrefix}}catch(w){return p(w)}}}},St=(e,t={})=>{const{maxRedirects:n=5,timeoutEachRedirect:o=1e4}=t;return{name:"oembed",processBlock:async(a,h)=>{const f=a.trim();if(!E.isValidUrl(f))throw new Error(`Invalid URL: ${f}`);try{const p=await E.fetchOEmbedData(f,n,o,h,e);return E.generateHtml(p,f,t)}catch(p){h.logger.warn("oEmbed fetch failed for URL:",f,p);const c=E.formatErrorInfo(p);return E.generateFallbackHtml(f,c)}}}},$t=(e={})=>({name:"card",processBlock:async(n,o)=>{const r=n.trim();if(!E.isValidUrl$1(r))throw new Error(`Invalid URL: ${r}`);try{const a=await E.fetchMetadata(r,e,o);return E.generateCardHtml(a,r,e)}catch(a){o.logger.warn("Card plugin fetch failed for URL:",r,a);const h=E.formatErrorInfo(a);return E.generateFallbackHtml$1(r,h)}}}),xt=(e={})=>{const{className:t="mermaid",includeId:n=!0}=e;return{name:"mermaid",processBlock:async(r,a)=>{const h=r.trim();if(!h){a.logger.warn("Mermaid plugin received empty content");const i=n?` id="${a.getUniqueId()}"`:"";return`<div class="${t}-wrapper">
|
|
15
14
|
<style>
|
|
16
15
|
.${t}-wrapper .${t} > svg {
|
|
17
16
|
width: auto !important;
|
|
@@ -19,8 +18,8 @@ ${ct(e)}---
|
|
|
19
18
|
max-width: none !important;
|
|
20
19
|
}
|
|
21
20
|
</style>
|
|
22
|
-
<div class="${t}"${
|
|
23
|
-
</div>`}const
|
|
21
|
+
<div class="${t}"${i}><!-- Empty mermaid content --></div>
|
|
22
|
+
</div>`}const f=n?` id="${a.getUniqueId()}"`:"",p=h.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),c=`<div class="${t}-wrapper">
|
|
24
23
|
<style>
|
|
25
24
|
.${t}-wrapper .${t} > svg {
|
|
26
25
|
width: auto !important;
|
|
@@ -28,14 +27,14 @@ ${ct(e)}---
|
|
|
28
27
|
max-width: none !important;
|
|
29
28
|
}
|
|
30
29
|
</style>
|
|
31
|
-
<div class="${t}"${
|
|
32
|
-
</div>`;return a.logger.debug("Mermaid plugin processed content:",{contentLength:
|
|
30
|
+
<div class="${t}"${f}>${p}</div>
|
|
31
|
+
</div>`;return a.logger.debug("Mermaid plugin processed content:",{contentLength:h.length,className:t,includeId:n}),c}}};/*!
|
|
33
32
|
* name: async-primitives
|
|
34
|
-
* version: 1.
|
|
33
|
+
* version: 1.4.0
|
|
35
34
|
* description: A collection of primitive functions for asynchronous operations
|
|
36
35
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
37
36
|
* license: MIT
|
|
38
37
|
* repository.url: https://github.com/kekyo/async-primitives.git
|
|
39
|
-
* git.commit.hash:
|
|
40
|
-
*/const
|
|
38
|
+
* git.commit.hash: 147b7bee11bf17823a185e0492d7f73587748715
|
|
39
|
+
*/const X=()=>{},tt={release:X,[Symbol.dispose]:X},Ht=(e,t)=>{if(!e)return tt;if(e.aborted){try{t()}catch(a){console.warn("AbortHook callback error: ",a)}return tt}let n;n=()=>{if(n){e.removeEventListener("abort",n),n=void 0;try{t()}catch(a){console.warn("AbortHook callback error: ",a)}}};const o=()=>{n&&(e.removeEventListener("abort",n),n=void 0)};return e.addEventListener("abort",n,{once:!0}),{release:o,[Symbol.dispose]:o}},Ct=e=>{typeof setImmediate=="function"?setImmediate(e):setTimeout(e,0)},W=()=>new Error("Lock acquisition was aborted"),Ft=e=>{let t=!0;const n=()=>{t&&(t=!1,e())};return{get isActive(){return t},release:n,[Symbol.dispose]:n}},B=(e=20)=>{let t=!1;const n=[];let o=0;const r=()=>{var i;if(t||n.length===0)return;const l=n.shift();if((i=l.signal)!=null&&i.aborted){l.reject(W()),a();return}t=!0;const s=Ft(h);l.resolve(s)},a=()=>{o++,o>=e?(o=0,Ct(r)):r()},h=()=>{t&&(t=!1,a())},f=i=>{const l=n.indexOf(i);l!==-1&&n.splice(l,1)},p=async i=>{if(i){if(i.aborted)throw W();return new Promise((l,s)=>{const u={resolve:void 0,reject:void 0,signal:i},d=Ht(i,()=>{f(u),s(W())});u.resolve=m=>{d.release(),l(m)},u.reject=m=>{d.release(),s(m)},n.push(u),r()})}else return new Promise((l,s)=>{n.push({resolve:l,reject:s}),r()})};return{lock:p,waiter:{wait:p},get isLocked(){return t},get pendingCount(){return n.length}}},Tt=(e="cache:")=>{const t=B(),n=()=>{try{return typeof window<"u"&&typeof window.localStorage<"u"&&window.localStorage!==null}catch{return!1}},o=async()=>{if(!n())return;const c=Date.now(),i=[];for(let l=0;l<localStorage.length;l++){const s=localStorage.key(l);if(!s||!s.startsWith(e))continue;const u=localStorage.getItem(s);if(u)try{const d=JSON.parse(u);d.ttl!==void 0&&(d.ttl===0||c>d.timestamp+d.ttl)&&i.push(s)}catch{i.push(s)}}for(const l of i)localStorage.removeItem(l)};return{get:async c=>{if(!n())throw new Error("localStorage is not available in this environment");const i=e+c,l=localStorage.getItem(i);if(!l)return null;let s;try{s=JSON.parse(l)}catch{const u=await t.lock();try{return localStorage.removeItem(i),null}finally{u.release()}}if(s.ttl!==void 0&&(s.ttl===0||Date.now()>s.timestamp+s.ttl)){const d=await t.lock();try{const m=Date.now();return(s.ttl===0||m>s.timestamp+s.ttl)&&localStorage.removeItem(i),null}finally{d.release()}}return s.data},set:async(c,i,l)=>{if(!n())throw new Error("localStorage is not available in this environment");const s=e+c,u={data:i,timestamp:Date.now()};l!==void 0&&(u.ttl=l);const d=JSON.stringify(u),m=await t.lock();try{try{localStorage.setItem(s,d)}catch(y){if(y instanceof Error&&y.name==="QuotaExceededError"){await o();try{localStorage.setItem(s,d)}catch(w){throw new Error(`Failed to store cache entry: ${w}`)}}else throw new Error(`Failed to store cache entry: ${y}`)}}finally{m.release()}},delete:async c=>{if(!n())throw new Error("localStorage is not available in this environment");const i=e+c,l=await t.lock();try{localStorage.removeItem(i)}finally{l.release()}},clear:async()=>{if(!n())throw new Error("localStorage is not available in this environment");const c=[];for(let l=0;l<localStorage.length;l++){const s=localStorage.key(l);s&&s.startsWith(e)&&c.push(s)}if(c.length===0)return;const i=await t.lock();try{for(const l of c)localStorage.removeItem(l)}finally{i.release()}},size:async()=>{if(!n())throw new Error("localStorage is not available in this environment");const c=[];for(let l=0;l<localStorage.length;l++){const s=localStorage.key(l);s&&s.startsWith(e)&&c.push(s)}if(c.length===0)return 0;const i=await t.lock();try{const l=Date.now();let s=0;for(const u of c){const d=localStorage.getItem(u);if(d)try{const m=JSON.parse(d);if(m.ttl!==void 0&&(m.ttl===0||l>m.timestamp+m.ttl)){localStorage.removeItem(u);continue}s++}catch{localStorage.removeItem(u)}}return s}finally{i.release()}}}},st=()=>{const e=new Map,t=B(),n=(p=Date.now())=>{const c=[];for(const[i,l]of e.entries())l.ttl!==void 0&&(l.ttl===0||p>l.timestamp+l.ttl)&&c.push(i);for(const i of c)e.delete(i);return c};return{get:async p=>{const c=e.get(p);if(!c)return null;if(c.ttl!==void 0&&(c.ttl===0||Date.now()>c.timestamp+c.ttl)){const l=await t.lock();try{const s=e.get(p);if(s&&s.ttl!==void 0){const u=Date.now();(s.ttl===0||u>s.timestamp+s.ttl)&&e.delete(p)}return null}finally{l.release()}}return c.data},set:async(p,c,i)=>{const l={data:c,timestamp:Date.now()};i!==void 0&&(l.ttl=i);const s=await t.lock();try{e.set(p,l)}finally{s.release()}},delete:async p=>{const c=await t.lock();try{e.delete(p)}finally{c.release()}},clear:async()=>{const p=await t.lock();try{e.clear()}finally{p.release()}},size:async()=>{if(Array.from(e.entries()).length===0)return 0;const c=await t.lock();try{return n(),e.size}finally{c.release()}}}},Ot=async e=>{try{const n=require("crypto").createHash("sha256");return n.update(e,"utf8"),n.digest("hex")}catch(t){throw new Error(`Failed to generate hash: ${t}`)}},It=e=>{if(typeof window<"u")throw new Error("File system cache is only available in Node.js environment, not in browsers");const t=B(),n=async c=>`${await Ot(c)}.json`,o=async()=>{try{const{promises:c}=require("fs");await c.mkdir(e,{recursive:!0})}catch(c){if(c.code!=="EEXIST")throw new Error(`Failed to create cache directory: ${c}`)}};return{get:async c=>{const i=await n(c);try{await o()}catch(m){throw new Error(`Failed to ensure cache directory: ${m}`)}const{promises:l}=require("fs"),u=require("path").join(e,i);let d;try{const m=await l.readFile(u,"utf-8");d=JSON.parse(m)}catch{return null}if(d.ttl!==void 0&&(d.ttl===0||Date.now()>d.timestamp+d.ttl)){const y=await t.lock();try{const w=Date.now();return(d.ttl===0||w>d.timestamp+d.ttl)&&await l.unlink(u),null}catch{return null}finally{y.release()}}return d.data},set:async(c,i,l)=>{const s=await n(c),u={data:i,timestamp:Date.now()};l!==void 0&&(u.ttl=l);const d=JSON.stringify(u,null,2),m=await t.lock();try{await o();const{promises:y}=require("fs"),g=require("path").join(e,s);try{await y.writeFile(g,d,"utf-8")}catch(v){throw new Error(`Failed to write cache entry: ${v}`)}}catch(y){throw new Error(`Failed to import required modules: ${y}`)}finally{m.release()}},delete:async c=>{const i=await n(c),l=await t.lock();try{await o();const{promises:s}=require("fs"),d=require("path").join(e,i);try{await s.unlink(d)}catch{}}catch(s){throw new Error(`Failed to import required modules: ${s}`)}finally{l.release()}},clear:async()=>{const c=await t.lock();try{await o();const{promises:i}=require("fs"),l=require("path"),u=(await i.readdir(e)).filter(d=>d.endsWith(".json"));for(const d of u){const m=l.join(e,d);try{await i.unlink(m)}catch{}}}catch(i){throw new Error(`Failed to import required modules: ${i}`)}finally{c.release()}},size:async()=>{await o();const{promises:c}=require("fs"),i=require("path"),s=(await c.readdir(e)).filter(d=>d.endsWith(".json"));if(s.length===0)return 0;const u=await t.lock();try{const d=Date.now();let m=0;for(const y of s){const w=i.join(e,y);try{const g=await c.readFile(w,"utf8"),v=JSON.parse(g);if(v.ttl!==void 0&&(v.ttl===0||d>v.timestamp+v.ttl)){await c.unlink(w);continue}m++}catch{try{await c.unlink(w)}catch{}}}return m}catch(d){throw new Error(`Failed to import required modules: ${d}`)}finally{u.release()}}}};function j(e,t,n){return`fetch:${e}:${t}:${n||"default"}`}const Nt=(e,t=6e4,n,o)=>{const{cache:r=!0,cacheTTL:a=3600*1e3,cacheFailures:h=!0,failureCacheTTL:f=300*1e3}=o||{},p=r?n||st():void 0;return{rawFetcher:async(i,l,s,u)=>{if(r&&p){const y=j(i,l,e),w=await p.get(y);if(w)try{const g=JSON.parse(w);if(g.type==="success")return u?.info(`Cache HIT (success) for URL: ${i}`),new Response(g.data,{status:200,statusText:"OK",headers:{"Content-Type":l,"X-Cache":"HIT"}});if(g.type==="error"&&h)throw u?.info(`Cache HIT (error) for URL: ${i}`),new Error("Cached error");u?.debug(`Cache entry type ${g.type} not eligible for use, cacheFailures: ${h}`)}catch(g){if(u?.warn(`Failed to parse cached entry for URL ${i}:`,g),g instanceof SyntaxError)u?.debug("JSON parse error, continuing to network fetch");else throw g}else u?.info(`Cache MISS for URL: ${i}`)}let d,m=null;try{d=await E.fetchData(i,l,e,t,s,u)}catch(y){if(m=y,r&&p&&h)try{const w=j(i,l,e),g={type:"error",data:"",error:{message:m.message,...m.message.includes("HTTP error, status:")&&{status:parseInt(m.message.match(/status: (\d+)/)?.[1]||"0")}},timestamp:Date.now()};await p.set(w,JSON.stringify(g),f),u?.debug(`Cached error for URL: ${i}`)}catch(w){u?.warn(`Failed to cache error for URL ${i}:`,w),console.warn("Failed to cache error:",w)}throw m}if(r&&p&&d.ok)try{const y=await d.clone().text(),w=j(i,l,e),g={type:"success",data:y,timestamp:Date.now()};await p.set(w,JSON.stringify(g),a),u?.debug(`Cached successful response for URL: ${i}`)}catch(y){u?.warn(`Failed to cache response for URL ${i}:`,y),console.warn("Failed to cache response:",y)}return d},userAgent:e}},Lt=(e,t=6e4)=>({rawFetcher:async(o,r,a,h)=>(h?.debug(`Direct fetch for URL: ${o}`),await E.fetchData(o,r,e,t,a,h)),userAgent:e});exports.defaultProviderList=E.defaultProviderList;exports.fetchData=E.fetchData;exports.fetchJson=E.fetchJson;exports.fetchText=E.fetchText;exports.generateHeadingId=E.generateHeadingId;exports.createCachedFetcher=Nt;exports.createCardPlugin=$t;exports.createDirectFetcher=Lt;exports.createFileSystemCacheStorage=It;exports.createLocalCacheStorage=Tt;exports.createMarkdownProcessor=kt;exports.createMemoryCacheStorage=st;exports.createMermaidPlugin=xt;exports.createOEmbedPlugin=St;exports.defaultHtmlOptions=at;exports.generateCacheKey=j;exports.getConsoleLogger=ft;exports.getNoOpLogger=nt;
|
|
41
40
|
//# sourceMappingURL=index.cjs.map
|