We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I added some code into mdict-parser.js and posted a pull-request months ago. This is a better method below.
mdict-parser.js
Usage
replace this line: return harvest(list.map(findWord)); with: return harvest(list.map(findWord)).map(replaceStyleMark);;
return harvest(list.map(findWord));
return harvest(list.map(findWord)).map(replaceStyleMark);;
function replaceStyleMark(content_string){ /** * Replace Mark to CsssStyle * Processing With: https://www.douban.com/note/526161004/ - 法汉汉法词典 * Niubility Dictionary Ultimate v1.0 */ var content_with_style = ""; //check if has special mark in content let content_style_keys = content_string.match(/`\d+`/g); if (content_style_keys == null || content_style_keys.length <= 0){ content_with_style = content_string; } else { //check if has stylesheet in mdx let styles_string = attrs['StyleSheet']; if (styles_string !== undefined && styles_string != null) { //make styles let styles_string_adjuested_space = (" " + styles_string.replace(/^\s*/g, '')); let style_strings = styles_string_adjuested_space.split(/ \d+ /g).filter(function (style) { return style.replace(/\s/g, '') !== ""; }); var styles = {}; $.each(style_strings, function (index, value) { let style_key = "`"+(index+1)+"`"; styles[style_key] = value; }); //make content breaks $.each(content_style_keys, function (index, style_key) { content_string = content_string.replace(new RegExp(style_key, 'g'), "<break>" + style_key); }); //loop content breaks $.each(content_string.split("<break>").filter(function (line) { return line.replace(/\s/g, '') !== ''; }), function (line_index, line) { //loop styles $.each(styles, function (key, style) { if (line.includes(key)){ let style_templates = style.match(new RegExp('<[^>]*>(\\s)+</[^>]*>', 'g')); if (style_templates !== null && style_templates.length === 1) { let template = style_templates[0]; let line_content = line.replace(new RegExp(key, 'g'), ''); let style_with_line_content = style.replace( template, template.replace(/>(\s)+</g, ">" + line_content + "<")); line = style_with_line_content; } else { line = line.replace(new RegExp(key, 'g'), style); } } }); content_with_style = content_with_style + line }); } //replace invalid content_style_key with <br> content_with_style = content_with_style.replace(/`\d+`/g, "<br>"); } return content_with_style; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I added some code into
mdict-parser.js
and posted a pull-request months ago. This is a better method below.Usage
replace this line:
return harvest(list.map(findWord));
with:
return harvest(list.map(findWord)).map(replaceStyleMark);;
The text was updated successfully, but these errors were encountered: