add addSpacingBetweenCnAndEn
This commit is contained in:
parent
b5486dff72
commit
d913092f99
|
@ -1357,6 +1357,8 @@ block dart-map-alternative
|
||||||
Framework developers may take this approach when they
|
Framework developers may take this approach when they
|
||||||
must acquire services generically and dynamically.
|
must acquire services generically and dynamically.
|
||||||
|
|
||||||
|
在框架程序员必须采用泛型或者动态方式获取服务时,他们可能采用这个方法。
|
||||||
|
|
||||||
+ifDocsFor('ts')
|
+ifDocsFor('ts')
|
||||||
.l-main-section#one-class-per-file
|
.l-main-section#one-class-per-file
|
||||||
:marked
|
:marked
|
||||||
|
|
|
@ -25,11 +25,10 @@ var sourceVisible = localStorage.getItem('source-visible') === 'true';
|
||||||
var count = 0;
|
var count = 0;
|
||||||
for (var i = 0; i < container.children.length; i++) {
|
for (var i = 0; i < container.children.length; i++) {
|
||||||
var node = container.children[i];
|
var node = container.children[i];
|
||||||
|
var ignoredTagNames = ['CODE-EXAMPLE', 'SCRIPT', 'CODE', 'EM'];
|
||||||
// ignore example code.
|
// ignore example code.
|
||||||
if (node.classList.contains('code-example') ||
|
if (node.classList.contains('code-example') ||
|
||||||
node.tagName === 'CODE-EXAMPLE' ||
|
ignoredTagNames.indexOf(node.tagName) >= 0) {
|
||||||
node.tagName === 'SCRIPT' || node.tagName === 'CODE') {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,6 +88,7 @@ var sourceVisible = localStorage.getItem('source-visible') === 'true';
|
||||||
$current.addClass('original-english');
|
$current.addClass('original-english');
|
||||||
$sibling.addClass('translated');
|
$sibling.addClass('translated');
|
||||||
$sibling.addClass('translated-cn');
|
$sibling.addClass('translated-cn');
|
||||||
|
addSpacingBetweenCnAndEn(sibling);
|
||||||
$sibling.after($current);
|
$sibling.after($current);
|
||||||
$sibling.on('click', function (event) {
|
$sibling.on('click', function (event) {
|
||||||
// for nested structure.
|
// for nested structure.
|
||||||
|
@ -106,7 +106,7 @@ var sourceVisible = localStorage.getItem('source-visible') === 'true';
|
||||||
}
|
}
|
||||||
|
|
||||||
function isPureEnglish(text) {
|
function isPureEnglish(text) {
|
||||||
if(text){
|
if (text) {
|
||||||
text = text.replace('在线例子', '');
|
text = text.replace('在线例子', '');
|
||||||
return /^[\1-\255—’“”ç®…à\u200B]*$/.test(text);
|
return /^[\1-\255—’“”ç®…à\u200B]*$/.test(text);
|
||||||
}
|
}
|
||||||
|
@ -132,4 +132,22 @@ var sourceVisible = localStorage.getItem('source-visible') === 'true';
|
||||||
return node1.tagName === node2.tagName &&
|
return node1.tagName === node2.tagName &&
|
||||||
attributesToString(node1) === attributesToString(node2);
|
attributesToString(node1) === attributesToString(node2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addSpacingBetweenCnAndEn(nodeCn) {
|
||||||
|
if (nodeCn.children) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var text = nodeCn.textContent;
|
||||||
|
console.log(text);
|
||||||
|
text = text.replace(/([\x20-\xff]+)/g, function (word) {
|
||||||
|
if (!word.replace(/\s/, '')) {
|
||||||
|
return '';
|
||||||
|
} else if (/<[^>]*>/.test(word)) {
|
||||||
|
return ' ' + word + ' ';
|
||||||
|
} else {
|
||||||
|
return ' ' + word + ' ';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
nodeCn.textContent = text;
|
||||||
|
}
|
||||||
})(angular.element);
|
})(angular.element);
|
||||||
|
|
Loading…
Reference in New Issue