You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2020/07/01 02:00:54 UTC
[incubator-echarts-doc] branch master updated: not parsing UI in
tutorial and api. fix parsing breaks the original article
This is an automated email from the ASF dual-hosted git repository.
shenyi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-echarts-doc.git
The following commit(s) were added to refs/heads/master by this push:
new a347d2a not parsing UI in tutorial and api. fix parsing breaks the original article
a347d2a is described below
commit a347d2a1b033242590be83f6a0717b6b5f172c86
Author: pissang <bm...@gmail.com>
AuthorDate: Wed Jul 1 09:59:21 2020 +0800
not parsing UI in tutorial and api. fix parsing breaks the original article
---
tool/md2json.js | 28 +++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/tool/md2json.js b/tool/md2json.js
index 3edb06f..af3aaa1 100644
--- a/tool/md2json.js
+++ b/tool/md2json.js
@@ -50,7 +50,7 @@ function convert(opts, cb) {
});
// Markdown to JSON
- var schema = mdToJsonSchema(mdStr, maxDepth, opts.imageRoot);
+ var schema = mdToJsonSchema(mdStr, maxDepth, opts.imageRoot, entry);
// console.log(mdStr);
var topLevel = schema.option.properties;
@@ -105,8 +105,9 @@ function convert(opts, cb) {
});
}
-function mdToJsonSchema(mdStr, maxDepth, imagePath) {
- var renderer = new marked.Renderer();
+function mdToJsonSchema(mdStr, maxDepth, imagePath, entry) {
+ const renderer = new marked.Renderer();
+ const originalHTMLRenderer = renderer.html;
renderer.link = function (href, title, text) {
if (href.match(/^~/)) { // Property link
return '<a href="#' + href.slice(1) + '">' + text + '</a>';
@@ -348,15 +349,20 @@ function mdToJsonSchema(mdStr, maxDepth, imagePath) {
// Avoid marked converting the markers in the code unexpectly.
// Like convert * to em.
// Also no need to decode entity
- section = section.replace(/(<\s*ExampleBaseOption[^>]*>)([\s\S]*?)(<\s*\/ExampleBaseOption\s*>)/g, function (text, openTag, code, closeTag) {
- const codeKey = codeKeyPrefx + (codeIndex++);
- codeMap[codeKey] = code;
- return openTag + codeKey + closeTag
- });
+ if (entry === 'option') {
+ section = section.replace(/(<\s*ExampleBaseOption[^>]*>)([\s\S]*?)(<\s*\/ExampleBaseOption\s*>)/g, function (text, openTag, code, closeTag) {
+ const codeKey = codeKeyPrefx + (codeIndex++);
+ codeMap[codeKey] = code;
+ return openTag + codeKey + closeTag;
+ });
+ renderer.html = function (html) {
+ return parseUIControl(html, property, codeMap);
+ };
+ }
+ else {
+ renderer.html = originalHTMLRenderer;
+ }
- renderer.html = function (html) {
- return parseUIControl(html, property, codeMap);
- };
property.description = marked(section, {
renderer: renderer
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org