Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
unidocs-uni-app-x-zh
提交
d4dba8fa
U
unidocs-uni-app-x-zh
项目概览
DCloud
/
unidocs-uni-app-x-zh
通知
156
Star
2
Fork
37
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
13
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
unidocs-uni-app-x-zh
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
13
合并请求
13
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
d4dba8fa
编写于
4月 24, 2024
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: inject-json-to-md 使用新的方式
上级
9356d903
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
152 addition
and
156 deletion
+152
-156
docs/.vuepress/markdown/inject-json-to-md.js
docs/.vuepress/markdown/inject-json-to-md.js
+152
-156
未找到文件。
docs/.vuepress/markdown/inject-json-to-md.js
浏览文件 @
d4dba8fa
let
cssJson
=
{}
;
let
cssJson
=
{}
let
utsJson
=
{}
;
let
utsJson
=
{}
let
utsApiJson
=
{}
;
let
utsApiJson
=
{}
let
utsComJson
=
{}
;
let
utsComJson
=
{}
let
utsUnicloudApiJson
=
{}
;
let
utsUnicloudApiJson
=
{}
let
customTypeJson
=
{}
;
let
customTypeJson
=
{}
let
vueJson
=
{}
;
let
vueJson
=
{}
let
manifestJson
=
{}
;
let
manifestJson
=
{}
let
pagesJson
=
{}
;
let
pagesJson
=
{}
let
specialStringJson
=
{}
;
let
specialStringJson
=
{}
let
pageInstanceJson
=
{}
;
let
pageInstanceJson
=
{}
try
{
try
{
cssJson
=
require
(
'
../utils/cssJson.json
'
);
cssJson
=
require
(
'
../utils/cssJson.json
'
)
}
catch
(
error
)
{}
}
catch
(
error
)
{}
try
{
try
{
utsJson
=
require
(
'
../utils/utsJson.json
'
);
utsJson
=
require
(
'
../utils/utsJson.json
'
)
}
catch
(
error
)
{}
}
catch
(
error
)
{}
try
{
try
{
utsApiJson
=
require
(
'
../utils/utsApiJson.json
'
);
utsApiJson
=
require
(
'
../utils/utsApiJson.json
'
)
}
catch
(
error
)
{}
}
catch
(
error
)
{}
try
{
try
{
utsComJson
=
require
(
'
../utils/utsComJson.json
'
);
utsComJson
=
require
(
'
../utils/utsComJson.json
'
)
}
catch
(
error
)
{}
}
catch
(
error
)
{}
try
{
try
{
utsUnicloudApiJson
=
require
(
'
../utils/utsUnicloudApiJson.json
'
);
utsUnicloudApiJson
=
require
(
'
../utils/utsUnicloudApiJson.json
'
)
}
catch
(
error
)
{}
}
catch
(
error
)
{}
try
{
try
{
customTypeJson
=
require
(
'
../utils/customTypeJson.json
'
);
customTypeJson
=
require
(
'
../utils/customTypeJson.json
'
)
}
catch
(
error
)
{}
}
catch
(
error
)
{}
try
{
try
{
vueJson
=
require
(
'
../utils/vueJson.json
'
);
vueJson
=
require
(
'
../utils/vueJson.json
'
)
}
catch
(
error
)
{}
}
catch
(
error
)
{}
try
{
try
{
manifestJson
=
require
(
'
../utils/maniFestJson.json
'
);
manifestJson
=
require
(
'
../utils/manifestJson.json
'
)
}
catch
(
error
)
{}
}
catch
(
error
)
{}
try
{
try
{
pagesJson
=
require
(
'
../utils/pagesJson.json
'
);
pagesJson
=
require
(
'
../utils/pagesJson.json
'
)
}
catch
(
error
)
{}
}
catch
(
error
)
{}
try
{
try
{
specialStringJson
=
require
(
'
../utils/specialStringJson.json
'
);
specialStringJson
=
require
(
'
../utils/specialStringJson.json
'
)
}
catch
(
error
)
{}
}
catch
(
error
)
{}
try
{
try
{
pageInstanceJson
=
require
(
'
../utils/pageInstanceJson.json
'
);
pageInstanceJson
=
require
(
'
../utils/pageInstanceJson.json
'
)
}
catch
(
error
)
{}
}
catch
(
error
)
{}
function
getRegExp
(
key
)
{
function
getRegExp
(
key
)
{
return
new
RegExp
(
`<!--\\s*
${
key
}
.([\\w\\W]+[^\\s])\\s*-->`
)
return
new
RegExp
(
`<!--\\s*
${
key
}
.([\\w\\W]+[^\\s])\\s*-->`
)
}
}
/**
*
* @param {string} text
* @returns {{match: RegExpMatchArray | null, json: {}}
*/
const
getJSON
=
text
=>
{
const
getJSON
=
text
=>
{
let
match
=
text
.
match
(
getRegExp
(
'
CSSJSON
'
));
let
match
=
text
.
match
(
getRegExp
(
'
CSSJSON
'
))
if
(
match
)
{
if
(
match
)
{
return
{
return
{
match
,
match
,
json
:
cssJson
,
json
:
cssJson
,
};
}
}
}
match
=
text
.
match
(
getRegExp
(
'
UTSJSON
'
));
match
=
text
.
match
(
getRegExp
(
'
UTSJSON
'
))
if
(
match
)
{
if
(
match
)
{
return
{
return
{
match
,
match
,
json
:
utsJson
,
json
:
utsJson
,
};
}
}
}
match
=
text
.
match
(
getRegExp
(
'
UTSAPIJSON
'
));
match
=
text
.
match
(
getRegExp
(
'
UTSAPIJSON
'
))
if
(
match
)
{
if
(
match
)
{
return
{
return
{
match
,
match
,
json
:
utsApiJson
,
json
:
utsApiJson
,
};
}
}
}
match
=
text
.
match
(
getRegExp
(
'
UTSCOMJSON
'
));
match
=
text
.
match
(
getRegExp
(
'
UTSCOMJSON
'
))
if
(
match
)
{
if
(
match
)
{
return
{
return
{
match
,
match
,
json
:
utsComJson
,
json
:
utsComJson
,
};
}
}
}
match
=
text
.
match
(
getRegExp
(
'
UTSUNICLOUDAPIJSON
'
));
match
=
text
.
match
(
getRegExp
(
'
UTSUNICLOUDAPIJSON
'
))
if
(
match
)
{
if
(
match
)
{
return
{
return
{
match
,
match
,
json
:
utsUnicloudApiJson
,
json
:
utsUnicloudApiJson
,
};
}
}
}
match
=
text
.
match
(
getRegExp
(
'
CUSTOMTYPEJSON
'
));
match
=
text
.
match
(
getRegExp
(
'
CUSTOMTYPEJSON
'
))
if
(
match
)
{
if
(
match
)
{
return
{
return
{
match
,
match
,
json
:
customTypeJson
,
json
:
customTypeJson
,
};
}
}
}
match
=
text
.
match
(
getRegExp
(
'
VUEJSON
'
));
match
=
text
.
match
(
getRegExp
(
'
VUEJSON
'
))
if
(
match
)
{
if
(
match
)
{
return
{
return
{
match
,
match
,
json
:
vueJson
,
json
:
vueJson
,
};
}
}
}
match
=
text
.
match
(
getRegExp
(
'
MANIFESTJSON
'
));
match
=
text
.
match
(
getRegExp
(
'
MANIFESTJSON
'
))
if
(
match
)
{
if
(
match
)
{
return
{
return
{
match
,
match
,
json
:
manifestJson
,
json
:
manifestJson
,
};
}
}
}
match
=
text
.
match
(
getRegExp
(
'
PAGESJSON
'
));
match
=
text
.
match
(
getRegExp
(
'
PAGESJSON
'
))
if
(
match
)
{
if
(
match
)
{
return
{
return
{
match
,
match
,
json
:
pagesJson
,
json
:
pagesJson
,
};
}
}
}
match
=
text
.
match
(
getRegExp
(
'
SPECIALSTRINGJSON
'
));
match
=
text
.
match
(
getRegExp
(
'
SPECIALSTRINGJSON
'
))
if
(
match
)
{
if
(
match
)
{
return
{
return
{
match
,
match
,
json
:
specialStringJson
,
json
:
specialStringJson
,
};
}
}
}
match
=
text
.
match
(
getRegExp
(
'
PAGEINSTANCE
'
));
match
=
text
.
match
(
getRegExp
(
'
PAGEINSTANCE
'
))
if
(
match
)
{
if
(
match
)
{
return
{
return
{
match
,
match
,
json
:
pageInstanceJson
,
json
:
pageInstanceJson
,
};
}
}
}
return
{
return
{
match
:
null
,
match
:
null
,
json
:
{},
json
:
{},
};
}
};
}
module
.
exports
=
function
(
md
,
opts
)
{
const
NEWLINE_CHARACTER
=
/
\r?\n
/
if
(
Object
.
keys
(
cssJson
)
===
0
)
return
false
;
md
.
core
.
ruler
.
after
(
'
inline
'
,
'
merge-css
'
,
function
(
state
)
{
module
.
exports
=
md
=>
{
const
ids
=
[]
md
.
parse
=
(
function
(
MD_PARSE
)
{
let
idIdx
=
1
return
function
(
src
,
...
args
)
{
for
(
let
index
=
0
;
index
<
state
.
tokens
.
length
;
index
++
)
{
if
(
src
&&
getJSON
(
src
).
match
)
{
const
blockToken
=
state
.
tokens
[
index
];
const
lines
=
src
.
split
(
NEWLINE_CHARACTER
)
if
(
blockToken
.
type
===
'
html_block
'
)
{
for
(
let
index
=
0
;
index
<
lines
.
length
;
index
++
)
{
const
{
match
,
json
}
=
getJSON
(
blockToken
.
content
);
const
line
=
lines
[
index
]
if
(
match
)
{
const
jsonPath
=
match
[
1
];
const
{
match
,
json
}
=
getJSON
(
line
)
const
path
=
jsonPath
.
split
(
'
.
'
);
if
(
match
)
{
let
temp
=
json
;
const
jsonPath
=
match
[
1
]
path
.
forEach
(
key
=>
{
const
path
=
jsonPath
.
split
(
'
.
'
)
if
(
!
temp
)
return
false
;
let
temp
=
json
temp
=
temp
[
key
];
path
.
forEach
(
key
=>
{
});
if
(
!
temp
)
return
false
if
(
!
temp
)
continue
;
temp
=
temp
[
key
]
const
parseTokens
=
md
.
parse
(
temp
);
})
parseTokens
.
forEach
(
token
=>
{
if
(
!
temp
)
continue
if
(
token
.
type
===
'
heading_open
'
)
{
lines
[
index
]
=
temp
const
id
=
token
.
attrGet
(
'
id
'
)
}
if
(
ids
.
includes
(
id
))
{
}
token
.
attrSet
(
'
id
'
,
`
${
id
}
_
${
idIdx
++
}
`
)
}
else
{
return
MD_PARSE
.
bind
(
this
)(
lines
.
join
(
'
\n
'
),
...
args
)
ids
.
push
(
id
)
}
}
return
MD_PARSE
.
bind
(
this
)(
src
,
...
args
)
}
}
})
})(
md
.
parse
)
state
.
tokens
.
splice
(
index
,
1
,
...
parseTokens
);
}
index
=
index
+
parseTokens
.
length
-
1
;
// blockToken.content = temp
}
}
}
return
false
;
});
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录