svelte-readme 3.6.0 → 3.6.3

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/CHANGELOG.md CHANGED
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [3.6.3](https://github.com/metonym/svelte-readme/releases/tag/v3.6.3) - 2022-02-25
9
+
10
+ - patch dependencies to resolve security warnings
11
+
12
+ ## [3.6.2](https://github.com/metonym/svelte-readme/releases/tag/v3.6.2) - 2021-12-29
13
+
14
+ - remove deprecated `svelteBracketNewLine` prettier option
15
+
16
+ ## [3.6.1](https://github.com/metonym/svelte-readme/releases/tag/v3.6.1) - 2021-11-14
17
+
18
+ - correctly render `h3` node text in table of contents
19
+
8
20
  ## [3.6.0](https://github.com/metonym/svelte-readme/releases/tag/v3.6.0) - 2021-10-27
9
21
 
10
22
  - evaluate but omit result if `no-display` attribute is present in Svelte code fence block
@@ -99,7 +99,7 @@ function createConfig(opts) {
99
99
  (0, preprocessReadme_1.preprocessReadme)(__assign(__assign({}, pkg), { prefixUrl: opts.prefixUrl })),
100
100
  ], false)
101
101
  };
102
- console.log("[createConfig] Running in " + (DEV ? "development" : "production"));
102
+ console.log("[createConfig] Running in ".concat(DEV ? "development" : "production"));
103
103
  console.log("[createConfig] options:");
104
104
  console.group();
105
105
  console.log("minify:", minify);
@@ -110,11 +110,11 @@ function createConfig(opts) {
110
110
  if (!opts.disableDefaultCSS) {
111
111
  css += "/**\n * GitHub Primer button CSS\n * https://primer.style/css/components/buttons\n **/\n .code-fence button {\n font-family: inherit;\n text-transform: none;\n position: relative;\n display: inline-block;\n padding: 5px 16px;\n font-size: 14px;\n font-weight: 500;\n line-height: 20px;\n white-space: nowrap;\n vertical-align: middle;\n cursor: pointer;\n user-select: none;\n border: 1px solid;\n border-radius: 6px;\n appearance: none;\n color: #24292e;\n background-color: #fafbfc;\n border-color: rgba(27,31,35,0.15);\n box-shadow: 0 1px 0 rgba(27,31,35,0.04), inset 0 1px 0 rgba(255,255,255,0.25);\n transition: background-color 0.2s cubic-bezier(0.3, 0, 0.5, 1);\n }";
112
112
  }
113
- var template = "\n <!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <meta name=\"description\" content=\"" + (pkg.description || pkg.name + " demo") + "\" />\n <title>" + pkg.name + "</title>\n <style>\n " + (!opts.disableDefaultCSS ? css : "") + "\n " + custom_css + "\n " + (opts.style || "") + "\n </style>\n " + ((_h = opts === null || opts === void 0 ? void 0 : opts.head) !== null && _h !== void 0 ? _h : "") + "\n </head>\n <body>\n <noscript>You need to enable JavaScript to run this app.</noscript>\n <script src=\"s" + hash + ".js\"></script>\n </body>\n </html>\n";
113
+ var template = "\n <!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <meta name=\"description\" content=\"".concat(pkg.description || "".concat(pkg.name, " demo"), "\" />\n <title>").concat(pkg.name, "</title>\n <style>\n ").concat(!opts.disableDefaultCSS ? css : "", "\n ").concat(custom_css, "\n ").concat(opts.style || "", "\n </style>\n ").concat((_h = opts === null || opts === void 0 ? void 0 : opts.head) !== null && _h !== void 0 ? _h : "", "\n </head>\n <body>\n <noscript>You need to enable JavaScript to run this app.</noscript>\n <script src=\"s").concat(hash, ".js\"></script>\n </body>\n </html>\n");
114
114
  if (minify)
115
115
  fs_extra_1["default"].removeSync(output_dir);
116
- fs_extra_1["default"].ensureFileSync(output_dir + "/index.html");
117
- fs_extra_1["default"].writeFileSync(output_dir + "/index.html", minify
116
+ fs_extra_1["default"].ensureFileSync("".concat(output_dir, "/index.html"));
117
+ fs_extra_1["default"].writeFileSync("".concat(output_dir, "/index.html"), minify
118
118
  ? html_minifier_1["default"].minify(template, {
119
119
  collapseWhitespace: true,
120
120
  conservativeCollapse: true,
@@ -126,7 +126,7 @@ function createConfig(opts) {
126
126
  watch: { clearScreen: false },
127
127
  input: "entry",
128
128
  // @ts-ignore
129
- output: __assign({ format: "iife", name: "app", file: output_dir + "/s" + hash + ".js" }, (opts.output || {})),
129
+ output: __assign({ format: "iife", name: "app", file: "".concat(output_dir, "/s").concat(hash, ".js") }, (opts.output || {})),
130
130
  plugins: __spreadArray(__spreadArray([
131
131
  (0, plugin_virtual_1["default"])({
132
132
  entry: "import App from \"./README.md\";\n const app = new App({ target: document.body });\n export default app;"
@@ -49,8 +49,15 @@ var aliases = {
49
49
  yml: "yaml"
50
50
  };
51
51
  var md;
52
+ var getChildNodeText = function (node) {
53
+ return node.children
54
+ .flatMap(function (child) { return (child.type === "Element" ? child.children : child); })
55
+ .filter(function (child) { return child.type === "Text"; })
56
+ .map(function (child) { return child.raw; })
57
+ .join("");
58
+ };
52
59
  function preprocessReadme(opts) {
53
- var prefixUrl = opts.prefixUrl || opts.homepage + "/tree/master/";
60
+ var prefixUrl = opts.prefixUrl || "".concat(opts.homepage, "/tree/master/");
54
61
  var script_content = [];
55
62
  if (!md) {
56
63
  md = new markdown_it_1["default"]({
@@ -72,20 +79,18 @@ function preprocessReadme(opts) {
72
79
  var regex = new RegExp('"' + opts.name + '"', "g");
73
80
  var modifiedSource = encodeURI(source.replace(regex, '"' + opts.svelte + '"'));
74
81
  var formattedCode = prettier_1["default"].format(source, {
75
- parser: "svelte",
76
- // @ts-ignore
77
- svelteBracketNewLine: true
82
+ parser: "svelte"
78
83
  });
79
84
  var svelteCode = prismjs_1["default"].highlight(formattedCode, prismjs_1["default"].languages.svelte, "svelte");
80
- return "<pre class=\"language-" + lang + "\" " + (noEval || noDisplay ? "" : "data-svelte=\"" + modifiedSource + "\"") + ">{@html `" + svelteCode + "`}</pre>";
85
+ return "<pre class=\"language-".concat(lang, "\" ").concat(noEval || noDisplay ? "" : "data-svelte=\"".concat(modifiedSource, "\""), ">{@html `").concat(svelteCode, "`}</pre>");
81
86
  }
82
87
  try {
83
88
  var alias_lang = aliases[lang] || lang;
84
- return "<pre class=\"language-" + alias_lang + "\">{@html `" + prismjs_1["default"].highlight(source, prismjs_1["default"].languages[alias_lang], alias_lang) + "`}</pre>";
89
+ return "<pre class=\"language-".concat(alias_lang, "\">{@html `").concat(prismjs_1["default"].highlight(source, prismjs_1["default"].languages[alias_lang], alias_lang), "`}</pre>");
85
90
  }
86
91
  catch (e) {
87
- console.error("Could not highlight language \"" + lang + "\".");
88
- return "<pre class=\"language-" + lang + "\">{@html `" + source + "`}</pre>";
92
+ console.error("Could not highlight language \"".concat(lang, "\"."));
93
+ return "<pre class=\"language-".concat(lang, "\">{@html `").concat(source, "`}</pre>");
89
94
  }
90
95
  }
91
96
  });
@@ -95,10 +100,10 @@ function preprocessReadme(opts) {
95
100
  // @ts-ignore
96
101
  markup: function (_a) {
97
102
  var content = _a.content, filename = _a.filename;
98
- if (/node_modules/.test(filename) || !filename.endsWith(".md"))
103
+ if (filename && (/node_modules/.test(filename) || !filename.endsWith(".md")))
99
104
  return null;
100
105
  if (opts.repoUrl) {
101
- content = content.replace("<!-- REPO_URL -->", "[GitHub repo](" + opts.repoUrl + ")");
106
+ content = content.replace("<!-- REPO_URL -->", "[GitHub repo](".concat(opts.repoUrl, ")"));
102
107
  }
103
108
  content = content.replace("<!-- TOC -->", "\n## Table of Contents\n ");
104
109
  var style_content = "";
@@ -128,17 +133,13 @@ function preprocessReadme(opts) {
128
133
  var id = node.attributes.find(function (attr) { return attr.name === "id"; }).value[0].raw;
129
134
  if (id === "table-of-contents")
130
135
  return;
131
- var text = node.children
132
- .flatMap(function (child) { return (child.type === "Element" ? child.children : child); })
133
- .filter(function (child) { return child.type === "Text"; })
134
- .map(function (child) { return child.raw; })
135
- .join("");
136
+ var text = getChildNodeText(node);
136
137
  if (text !== undefined) {
137
138
  if (prev === "h3") {
138
- headings.push("</ul><li><a href=\"#" + id + "\">" + text + "</a></li>");
139
+ headings.push("</ul><li><a href=\"#".concat(id, "\">").concat(text, "</a></li>"));
139
140
  }
140
141
  else {
141
- headings.push("<li><a href=\"#" + id + "\">" + text + "</a></li>");
142
+ headings.push("<li><a href=\"#".concat(id, "\">").concat(text, "</a></li>"));
142
143
  }
143
144
  prev = "h2";
144
145
  }
@@ -146,13 +147,13 @@ function preprocessReadme(opts) {
146
147
  if (node.type === "Element" && node.name === "h3") {
147
148
  // @ts-ignore
148
149
  var id = node.attributes.find(function (attr) { return attr.name === "id"; }).value[0].raw;
149
- var text = node.children[0].raw;
150
+ var text = getChildNodeText(node);
150
151
  if (text !== undefined) {
151
152
  if (prev === "h2") {
152
- headings.push("<ul><li><a href=\"#" + id + "\">" + text + "</a></li>");
153
+ headings.push("<ul><li><a href=\"#".concat(id, "\">").concat(text, "</a></li>"));
153
154
  }
154
155
  else {
155
- headings.push("<li><a href=\"#" + id + "\">" + text + "</a></li>");
156
+ headings.push("<li><a href=\"#".concat(id, "\">").concat(text, "</a></li>"));
156
157
  }
157
158
  prev = "h3";
158
159
  }
@@ -171,9 +172,9 @@ function preprocessReadme(opts) {
171
172
  if (prev === "h3") {
172
173
  headings.push("</ul>");
173
174
  }
174
- result = result.replace("<h2 id=\"table-of-contents\">Table of Contents</h2>", "<p><strong>Table of Contents</strong></p><ul>" + headings.join("\n") + "</ul>");
175
+ result = result.replace("<h2 id=\"table-of-contents\">Table of Contents</h2>", "<p><strong>Table of Contents</strong></p><ul>".concat(headings.join("\n"), "</ul>"));
175
176
  return {
176
- code: "<script>" + __spreadArray([], __read(new Set(script_content)), false).join("") + "</script>\n <style>" + style_content + "</style>\n <main class=\"markdown-body\">" + result + "</main>"
177
+ code: "<script>".concat(__spreadArray([], __read(new Set(script_content)), false).join(""), "</script>\n <style>").concat(style_content, "</style>\n <main class=\"markdown-body\">").concat(result, "</main>")
177
178
  };
178
179
  }
179
180
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-readme",
3
- "version": "3.6.0",
3
+ "version": "3.6.3",
4
4
  "license": "MIT",
5
5
  "description": "Develop and demo your Svelte components in your README.md",
6
6
  "author": "Eric Liu (https://github.com/metonym)",
@@ -9,7 +9,8 @@
9
9
  "scripts": {
10
10
  "preprocess": "node scripts/preprocessStyles",
11
11
  "dev": "yarn preprocess && tsc -w",
12
- "prepack": "yarn preprocess && tsc"
12
+ "prepack": "yarn preprocess && tsc",
13
+ "format": "prettier --ignore-path .gitignore --write ."
13
14
  },
14
15
  "dependencies": {
15
16
  "@rollup/plugin-node-resolve": "^11.1.0",
@@ -17,19 +18,19 @@
17
18
  "fs-extra": "^9.0.1",
18
19
  "html-minifier": "^4.0.0",
19
20
  "is-relative-url": "^3.0.0",
20
- "markdown-it": "^12.0.4",
21
+ "markdown-it": "^12.3.0",
21
22
  "markdown-it-anchor": "^6.0.1",
22
- "prettier": "^2.2.1",
23
- "prettier-plugin-svelte": "^2.1.0",
23
+ "prettier": "^2.5.1",
24
+ "prettier-plugin-svelte": "^2.5.1",
24
25
  "prism-svelte": "^0.4.7",
25
26
  "prismjs": "^1.23.0",
26
- "rollup": "^2.36.2",
27
+ "rollup": "^2.62.0",
27
28
  "rollup-plugin-svelte": "^7.0.0",
28
29
  "rollup-plugin-terser": "^7.0.2"
29
30
  },
30
31
  "devDependencies": {
31
32
  "@types/fs-extra": "^9.0.6",
32
- "@types/html-minifier": "^4.0.0",
33
+ "@types/html-minifier": "^4.0.2",
33
34
  "@types/markdown-it": "^12.0.1",
34
35
  "@types/markdown-it-anchor": "^4.0.4",
35
36
  "@types/node": "^14.14.21",