diff --git a/docs/js/quote-translate.js b/docs/js/quote-translate.js index 74cfe63..ed53f6d 100644 --- a/docs/js/quote-translate.js +++ b/docs/js/quote-translate.js @@ -1,20 +1,16 @@ document.addEventListener('DOMContentLoaded', function () { - document.querySelectorAll('blockquote[data-cn]').forEach(function (el) { - const cn = el.getAttribute('data-cn').split('|'); - // 收集所有文本节点 - const walker = document.createTreeWalker(el, NodeFilter.SHOW_TEXT); - const nodes = []; - while (walker.nextNode()) nodes.push(walker.currentNode); - // 存原文 - const orig = nodes.map(n => n.textContent); + document.querySelectorAll('blockquote').forEach(function (el) { + const ps = el.querySelectorAll('p[data-cn]'); + if (!ps.length) return; + + const originals = Array.from(ps).map(p => p.textContent); + const translations = Array.from(ps).map(p => p.getAttribute('data-cn')); let showing = 'orig'; function swap(to) { - if (to === 'cn') { - cn.forEach((text, i) => { if (nodes[i]) nodes[i].textContent = text; }); - } else { - orig.forEach((text, i) => { if (nodes[i]) nodes[i].textContent = text; }); - } + ps.forEach((p, i) => { + p.textContent = to === 'cn' ? translations[i] : originals[i]; + }); showing = to; } diff --git a/docs/shared/new-saas-revolution.md b/docs/shared/new-saas-revolution.md index e6a7f05..c318ac2 100644 --- a/docs/shared/new-saas-revolution.md +++ b/docs/shared/new-saas-revolution.md @@ -13,16 +13,16 @@ echo "of the human, by the human, for the human" | sed 's/human/AI/g' --- -
-Umwertung aller Werte.
-— Nietzsche
++--- -Umwertung aller Werte.
+— Nietzsche
-Die Proletarier haben nichts in ihr zu verlieren als ihre Ketten. Sie haben eine Welt zu gewinnen.
-— Marx
++--- @@ -34,23 +34,23 @@ echo "of the human, by the human, for the human" | sed 's/human/AI/g' --- -Die Proletarier haben nichts in ihr zu verlieren als ihre Ketten. Sie haben eine Welt zu gewinnen.
+— Marx
-I have a dream, today.
-— Martin Luther King Jr.
++--- -I have a dream, today.
+— Martin Luther King Jr.
-of the people, by the people, for the people.
-— Lincoln
++--- -of the people, by the people, for the people.
+— Lincoln
-Hasta la victoria siempre.
-— Che Guevara
++---Hasta la victoria siempre.
+— Che Guevara