clean: remove unused files
This commit is contained in:
parent
1ec5c6a82f
commit
bbe6ac9014
|
@ -1,24 +0,0 @@
|
|||
function mark(text) {
|
||||
return text.replace(/<(h\d|header|p|a)([\s\S]*?)>([\s\S]+?)<\/\1>/gi, function ($0, $1, $2, $3) {
|
||||
const suffix = isTranslation($3) ? 'result' : 'origin=off';
|
||||
return `<${$1} translation-${suffix} ${$2}>${$3}</${$1}>`;
|
||||
});
|
||||
}
|
||||
|
||||
function swap(text) {
|
||||
return text.replace(/<(\w+)( translation-origin\b[\s\S]*?)<\/\1>(\s*)<\1( translation-result\b[\s\S]*?)<\/\1>/gi, '<$1$4</$1>$3<$1$2</$1>');
|
||||
}
|
||||
|
||||
function markAndSwap(text) {
|
||||
return swap(mark(text));
|
||||
}
|
||||
|
||||
function isTranslation(text) {
|
||||
return text && /[\u2E80-\u2EFF\u2F00-\u2FDF\u3000-\u303F\u31C0-\u31EF\u3200-\u32FF\u3300-\u33FF\u3400-\u4DBF\u4DC0-\u4DFF\u4E00-\u9FBF\uF900-\uFAFF\uFE30-\uFE4F\uFF00-\uFFEF]/.test(text);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
mark,
|
||||
swap,
|
||||
markAndSwap,
|
||||
};
|
|
@ -1,13 +0,0 @@
|
|||
const { expect } = require('chai');
|
||||
|
||||
const { mark, swap } = require('./translator');
|
||||
|
||||
it('mark translation results and origins', () => {
|
||||
expect(mark('<h1>AngularJS to Angular</h1>\n<h1>从 AngularJS 到 Angular 快速参考</h1>'))
|
||||
.equal('<h1 translation-origin=off >AngularJS to Angular</h1>\n<h1 translation-result >从 AngularJS 到 Angular 快速参考</h1>');
|
||||
});
|
||||
|
||||
it('swap result and origin', () => {
|
||||
expect(swap('<h1 translation-origin=off >AngularJS to Angular</h1>\n<h1 translation-result >从 AngularJS 到 Angular 快速参考</h1>'))
|
||||
.equal('<h1 translation-result >从 AngularJS 到 Angular 快速参考</h1>\n<h1 translation-origin=off >AngularJS to Angular</h1>');
|
||||
});
|
Loading…
Reference in New Issue