@md-plugins/md-plugin-image 0.1.0-alpha.25 → 0.1.0-alpha.26

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
@@ -13,12 +13,12 @@ A **Markdown-It** plugin that enhances image rendering by adding customizable CS
13
13
  Install the plugin via your preferred package manager:
14
14
 
15
15
  ```bash
16
- # With npm:
17
- npm install @md-plugins/md-plugin-image
18
- # Or with Yarn:
19
- yarn add @md-plugins/md-plugin-image
20
- # Or with pnpm:
16
+ # with pnpm:
21
17
  pnpm add @md-plugins/md-plugin-image
18
+ # with Yarn:
19
+ yarn add @md-plugins/md-plugin-image
20
+ # with npm:
21
+ npm install @md-plugins/md-plugin-image
22
22
  ```
23
23
 
24
24
  ## Usage
package/dist/index.mjs CHANGED
@@ -8,19 +8,19 @@ const imagePlugin = (md, { imageClass = "markdown-image" } = {}) => {
8
8
  let content = token.content;
9
9
  const widthMatch = content.match(/width="(\d+)"/);
10
10
  const heightMatch = content.match(/height="(\d+)"/);
11
- if (widthMatch) {
11
+ if (widthMatch && widthMatch.length > 1) {
12
12
  token.attrSet("width", widthMatch[1]);
13
13
  content = content.replace(widthMatch[0], "").trim();
14
14
  }
15
- if (heightMatch) {
15
+ if (heightMatch && heightMatch.length > 1) {
16
16
  token.attrSet("height", heightMatch[1]);
17
17
  content = content.replace(heightMatch[0], "").trim();
18
18
  }
19
19
  if (content) {
20
20
  const altIndex = token.attrIndex("alt");
21
- if (altIndex >= 0 && token.attrs) {
21
+ if (altIndex >= 0 && token.attrs && token.attrs[altIndex] && token.attrs[altIndex].length > 1) {
22
22
  const altValue = token.attrs[altIndex][1];
23
- if (!altValue) {
23
+ if (!altValue && altIndex) {
24
24
  token.attrs[altIndex][1] = content;
25
25
  }
26
26
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@md-plugins/md-plugin-image",
3
- "version": "0.1.0-alpha.25",
3
+ "version": "0.1.0-alpha.26",
4
4
  "description": "A markdown-it plugin for handling images.",
5
5
  "keywords": [
6
6
  "markdown-it",
@@ -35,7 +35,7 @@
35
35
  "devDependencies": {
36
36
  "markdown-it": "^14.1.0",
37
37
  "@types/markdown-it": "^14.1.2",
38
- "@md-plugins/shared": "0.1.0-alpha.25"
38
+ "@md-plugins/shared": "0.1.0-alpha.26"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "markdown-it": "^14.1.0"