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
|
||||
must acquire services generically and dynamically.
|
||||
|
||||
在框架程序员必须采用泛型或者动态方式获取服务时,他们可能采用这个方法。
|
||||
|
||||
+ifDocsFor('ts')
|
||||
.l-main-section#one-class-per-file
|
||||
:marked
|
||||
|
|
|
@ -25,11 +25,10 @@ var sourceVisible = localStorage.getItem('source-visible') === 'true';
|
|||
var count = 0;
|
||||
for (var i = 0; i < container.children.length; i++) {
|
||||
var node = container.children[i];
|
||||
|
||||
var ignoredTagNames = ['CODE-EXAMPLE', 'SCRIPT', 'CODE', 'EM'];
|
||||
// ignore example code.
|
||||
if (node.classList.contains('code-example') ||
|
||||
node.tagName === 'CODE-EXAMPLE' ||
|
||||
node.tagName === 'SCRIPT' || node.tagName === 'CODE') {
|
||||
ignoredTagNames.indexOf(node.tagName) >= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -89,6 +88,7 @@ var sourceVisible = localStorage.getItem('source-visible') === 'true';
|
|||
$current.addClass('original-english');
|
||||
$sibling.addClass('translated');
|
||||
$sibling.addClass('translated-cn');
|
||||
addSpacingBetweenCnAndEn(sibling);
|
||||
$sibling.after($current);
|
||||
$sibling.on('click', function (event) {
|
||||
// for nested structure.
|
||||
|
@ -132,4 +132,22 @@ var sourceVisible = localStorage.getItem('source-visible') === 'true';
|
|||
return node1.tagName === node2.tagName &&
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue