in tool/md2json.js [323:422]
function move(section, idx) {
var text = headers[idx].text;
var parts = /(.*)\(([\w\|\*]*)\)(\s*=\s*(.*))*/.exec(text);
var key;
var type = '*';
var defaultValue = null;
var level = headers[idx].level;
if (parts === null) {
key = text;
}
else {
key = parts[1];
type = parts[2];
defaultValue = parts[4] || null;
}
var types = type.split('|').map(function (item) {
return item.trim();
});
key = key.trim();
var property = {
'type': types,
// exampleBaseOptions
// uiControl
'description': ''
};
// section = parseUIControl(section, property);
section = section.replace(/~\[(.*)\]\((.*)\)/g, function (text, size, href) {
size = size.split('x');
var iframe = ['<iframe data-src="', href, '"'];
if (size[0].match(/[0-9%]/)) {
iframe.push(' width="', size[0], '"');
}
if (size[1].match(/[0-9%]/)) {
iframe.push(' height="', size[1], '"');
}
iframe.push(' ></iframe>\n');
return iframe.join('');
});
const codeMap = {};
const codeKeyPrefx = 'example_base_option_code_';
let codeIndex= 0;
// Convert the code the a simple key.
// Avoid marked converting the markers in the code unexpectly.
// Like convert * to em.
// Also no need to decode entity
if (entry === 'option' || entry === 'option-gl') {
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;
}
property.description = marked(section, {
renderer: renderer
});
if (defaultValue != null) {
property['default'] = convertType(defaultValue);
}
if (level < currentLevel) {
var diff = currentLevel - level;
var count = 0;
while (count <= diff) {
stacks.pop();
count++;
}
appendProperty(key, property);
current = property;
stacks.push(current);
}
else if (level > currentLevel) {
if (level - currentLevel > 1) {
throw new Error(
text + '\n标题层级 "' + repeat('#', level) + '" 不能直接跟在标题层级 "' + repeat('#', currentLevel) + '"后'
);
}
current = property;
appendProperty(key, property);
stacks.push(current);
}
else {
stacks.pop();
appendProperty(key, property);
stacks.push(property);
}
currentLevel = level;
}