marked-images 2.2.0 → 3.0.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/LICENSE +1 -1
- package/README.md +18 -3
- package/marked-images.js +22 -6
- package/package.json +5 -5
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(The MIT License)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2015-
|
|
3
|
+
Copyright (c) 2015-2022 Jürgen Leschner -- github.com/jldec
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
6
|
a copy of this software and associated documentation files (the
|
package/README.md
CHANGED
|
@@ -11,8 +11,11 @@ npm install marked-images
|
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
## usage
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
|
|
15
|
+
*NOTE: breaking changes:*
|
|
16
|
+
|
|
17
|
+
- As of v2.0.0, this library uses the [`marked.use()`](https://marked.js.org/#/USING_PRO.md#use) plugin api.
|
|
18
|
+
- As of v3.0.0, since [marked v4.x](https://github.com/markedjs/marked/releases/tag/v4.0.0) the `marked()` function is no longer the default export. CommonJS code which does `marked = require(marked)` should be changed to call `marked.marked(<markdown-string>)` instead of `marked()`.
|
|
16
19
|
|
|
17
20
|
```javascript
|
|
18
21
|
var marked = require('marked');
|
|
@@ -29,7 +32,7 @@ var opts = {
|
|
|
29
32
|
|
|
30
33
|
marked.use(markedImages(opts));
|
|
31
34
|
|
|
32
|
-
var html = marked(markdown);
|
|
35
|
+
var html = marked.marked(markdown);
|
|
33
36
|
```
|
|
34
37
|
|
|
35
38
|
#### simple width and height
|
|
@@ -58,6 +61,18 @@ generates:
|
|
|
58
61
|
<img src="src" alt="" width="1" height="2" align="right" title="title text">
|
|
59
62
|
```
|
|
60
63
|
|
|
64
|
+
#### CSS classnames
|
|
65
|
+
.{classname}
|
|
66
|
+
|
|
67
|
+
```md
|
|
68
|
+
 => width="100" height="50"
|
|
12
|
+
* - pattern attr=value (with no quotes) E.g. 
|
|
13
|
+
* - pattern .className E.g.  => class="foo bar"
|
|
8
14
|
*
|
|
9
15
|
* usage: marked.use(markedImages(opts))
|
|
10
16
|
*
|
|
11
17
|
* original function: copyright Christopher Jeffrey -- https://github.com/markedjs/marked (MIT License)
|
|
12
|
-
* extension
|
|
18
|
+
* extension Copyright (c) 2015-2022 Jürgen Leschner - github.com/jldec/ - MIT license
|
|
13
19
|
*
|
|
14
20
|
**/
|
|
15
21
|
|
|
@@ -43,12 +49,22 @@ module.exports = function markedImages(opts) {
|
|
|
43
49
|
|
|
44
50
|
var a = (title && title.split(/\s+/)) || [];
|
|
45
51
|
var b = [];
|
|
52
|
+
var classNames = [];
|
|
46
53
|
var m;
|
|
47
54
|
a.forEach(function(w) {
|
|
48
55
|
if ((m = w.match(/^(\d+)x(\d+)$/))) return (out += ' width="' + m[1] + '" height="' + m[2] + '"');
|
|
49
|
-
if ((m = w.match(/^(\w+)=([\w-]+)$/)))
|
|
56
|
+
if ((m = w.match(/^(\w+)=([\w-]+)$/))) {
|
|
57
|
+
if (m[1] === 'class') return classNames.push(m[2]);
|
|
58
|
+
return (out += ' ' + m[1] + '="' + m[2] + '"');
|
|
59
|
+
}
|
|
60
|
+
if ((m = w.match(/^\.([\w-]+)$/))) return classNames.push(m[1]);
|
|
50
61
|
if (w) return b.push(w);
|
|
51
62
|
});
|
|
63
|
+
|
|
64
|
+
if (classNames.length) {
|
|
65
|
+
out += ' class="' + classNames.join(' ') + '"';
|
|
66
|
+
}
|
|
67
|
+
|
|
52
68
|
title = b.join(' ');
|
|
53
69
|
|
|
54
70
|
if (title) {
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "marked-images",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Simple marked renderer for image attributes in markdown. Also generates vimeo links.",
|
|
5
5
|
"main": "marked-images.js",
|
|
6
6
|
"peerDependencies": {
|
|
7
|
-
"marked": "^
|
|
7
|
+
"marked": "^4.0.10"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"lodash.startswith": "^4.2.1"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
|
-
"eslint": "^7.
|
|
14
|
-
"marked": "^
|
|
15
|
-
"tape": "^5.
|
|
13
|
+
"eslint": "^8.7.0",
|
|
14
|
+
"marked": "^4.0.10",
|
|
15
|
+
"tape": "^5.4.1"
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
18
|
"marked-images.js"
|