remark-inline-svg-flex 0.3.3 → 0.3.5
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 +1 -1
- package/dist/cjs/plugin.d.ts +2 -2
- package/dist/cjs/plugin.js +6 -6
- package/dist/plugin.d.ts +2 -2
- package/dist/plugin.js +5 -5
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/cjs/plugin.d.ts
CHANGED
|
@@ -10,5 +10,5 @@ import type { Options } from './types';
|
|
|
10
10
|
* @param options.wrapper - Optional HTML wrapper for the inline SVG (default: `<figure class="inline-svg"></figure>`)
|
|
11
11
|
* @param options.svgo - Whether to optimize SVG using SVGO (default: true)
|
|
12
12
|
*/
|
|
13
|
-
declare const
|
|
14
|
-
export {
|
|
13
|
+
declare const remarkInlineSvg: Plugin<[Options?], Root, Root>;
|
|
14
|
+
export { remarkInlineSvg };
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.remarkInlineSvg = void 0;
|
|
4
4
|
const node_path_1 = require("node:path");
|
|
5
5
|
const node_fs_1 = require("node:fs");
|
|
6
6
|
const unist_util_visit_1 = require("unist-util-visit");
|
|
@@ -14,7 +14,7 @@ const svgo_1 = require("svgo");
|
|
|
14
14
|
* @param options.wrapper - Optional HTML wrapper for the inline SVG (default: `<figure class="inline-svg"></figure>`)
|
|
15
15
|
* @param options.svgo - Whether to optimize SVG using SVGO (default: true)
|
|
16
16
|
*/
|
|
17
|
-
const
|
|
17
|
+
const remarkInlineSvg = (consumerOptions = {}) => {
|
|
18
18
|
const options = {
|
|
19
19
|
suffix: consumerOptions.suffix ?? '.svg',
|
|
20
20
|
assetsDir: consumerOptions.assetsDir,
|
|
@@ -39,7 +39,7 @@ const inlineSvg = (consumerOptions = {}) => {
|
|
|
39
39
|
});
|
|
40
40
|
};
|
|
41
41
|
};
|
|
42
|
-
exports.
|
|
42
|
+
exports.remarkInlineSvg = remarkInlineSvg;
|
|
43
43
|
/**
|
|
44
44
|
* Reads an SVG file and optionally optimizes it with SVGO.
|
|
45
45
|
*/
|
|
@@ -61,7 +61,7 @@ function wrap(svgString, htmlWrapper) {
|
|
|
61
61
|
* Resolves the final SVG file path based on:
|
|
62
62
|
* 1) absolute URL → from project root
|
|
63
63
|
* 2) `assetsDir` → relative to it
|
|
64
|
-
* 3) fallback → relative to Markdown file directory
|
|
64
|
+
* 3) fallback → relative to Markdown file directory (if markdown file directory is undefined use absolute URL)
|
|
65
65
|
*/
|
|
66
66
|
function resolvePath(assetsDir, node, markdownFileDir) {
|
|
67
67
|
if (node_path_1.default.isAbsolute(node.url)) {
|
|
@@ -71,7 +71,7 @@ function resolvePath(assetsDir, node, markdownFileDir) {
|
|
|
71
71
|
return node_path_1.default.resolve(process.cwd(), assetsDir, node.url);
|
|
72
72
|
}
|
|
73
73
|
else {
|
|
74
|
-
return node_path_1.default.resolve(markdownFileDir, node.url);
|
|
74
|
+
return node_path_1.default.resolve(markdownFileDir ?? process.cwd(), node.url);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
@@ -79,6 +79,6 @@ function resolvePath(assetsDir, node, markdownFileDir) {
|
|
|
79
79
|
*/
|
|
80
80
|
function optimizeSvg(svgString) {
|
|
81
81
|
return (0, svgo_1.optimize)(svgString, {
|
|
82
|
-
plugins: ['preset-default', 'removeXMLNS'
|
|
82
|
+
plugins: ['preset-default', 'removeXMLNS'],
|
|
83
83
|
});
|
|
84
84
|
}
|
package/dist/plugin.d.ts
CHANGED
|
@@ -10,5 +10,5 @@ import type { Options } from './types';
|
|
|
10
10
|
* @param options.wrapper - Optional HTML wrapper for the inline SVG (default: `<figure class="inline-svg"></figure>`)
|
|
11
11
|
* @param options.svgo - Whether to optimize SVG using SVGO (default: true)
|
|
12
12
|
*/
|
|
13
|
-
declare const
|
|
14
|
-
export {
|
|
13
|
+
declare const remarkInlineSvg: Plugin<[Options?], Root, Root>;
|
|
14
|
+
export { remarkInlineSvg };
|
package/dist/plugin.js
CHANGED
|
@@ -12,7 +12,7 @@ import { optimize } from 'svgo';
|
|
|
12
12
|
* @param options.wrapper - Optional HTML wrapper for the inline SVG (default: `<figure class="inline-svg"></figure>`)
|
|
13
13
|
* @param options.svgo - Whether to optimize SVG using SVGO (default: true)
|
|
14
14
|
*/
|
|
15
|
-
const
|
|
15
|
+
const remarkInlineSvg = (consumerOptions = {}) => {
|
|
16
16
|
const options = {
|
|
17
17
|
suffix: consumerOptions.suffix ?? '.svg',
|
|
18
18
|
assetsDir: consumerOptions.assetsDir,
|
|
@@ -58,7 +58,7 @@ function wrap(svgString, htmlWrapper) {
|
|
|
58
58
|
* Resolves the final SVG file path based on:
|
|
59
59
|
* 1) absolute URL → from project root
|
|
60
60
|
* 2) `assetsDir` → relative to it
|
|
61
|
-
* 3) fallback → relative to Markdown file directory
|
|
61
|
+
* 3) fallback → relative to Markdown file directory (if markdown file directory is undefined use absolute URL)
|
|
62
62
|
*/
|
|
63
63
|
function resolvePath(assetsDir, node, markdownFileDir) {
|
|
64
64
|
if (path.isAbsolute(node.url)) {
|
|
@@ -68,7 +68,7 @@ function resolvePath(assetsDir, node, markdownFileDir) {
|
|
|
68
68
|
return path.resolve(process.cwd(), assetsDir, node.url);
|
|
69
69
|
}
|
|
70
70
|
else {
|
|
71
|
-
return path.resolve(markdownFileDir, node.url);
|
|
71
|
+
return path.resolve(markdownFileDir ?? process.cwd(), node.url);
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
@@ -76,7 +76,7 @@ function resolvePath(assetsDir, node, markdownFileDir) {
|
|
|
76
76
|
*/
|
|
77
77
|
function optimizeSvg(svgString) {
|
|
78
78
|
return optimize(svgString, {
|
|
79
|
-
plugins: ['preset-default', 'removeXMLNS'
|
|
79
|
+
plugins: ['preset-default', 'removeXMLNS'],
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
|
-
export {
|
|
82
|
+
export { remarkInlineSvg };
|
package/package.json
CHANGED