Skip to content

Commit 51a8c63

Browse files
authored
Merge branch 'cppdoc-cc:main' into main
2 parents 7388527 + 4b575c9 commit 51a8c63

File tree

4 files changed

+12
-17
lines changed

4 files changed

+12
-17
lines changed

migrate/migrate-bot.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import path, { join } from "path";
55
import { fileURLToPath } from "url";
66
import { execSync, spawnSync } from "child_process";
77
import { visualizeTextDiff } from "./text-diff-visualizer";
8-
import { convert } from "html-to-text";
98

109
const __dirname = path.dirname(fileURLToPath(import.meta.url));
1110

@@ -85,11 +84,14 @@ async function fetchPageContent(
8584
if (!contentElement) {
8685
throw new Error("Could not find #mw-content-text");
8786
}
87+
88+
const title = headingElement?.textContent?.trim() || "";
89+
8890
return {
8991
html: contentElement.innerHTML,
90-
title: headingElement?.textContent?.trim() || "",
92+
title,
9193
url,
92-
innerText: (contentElement as HTMLDivElement).innerText,
94+
innerText: title + "\n" + (contentElement as HTMLDivElement).innerText,
9395
};
9496
}
9597

migrate/text-diff-visualizer.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function parseText(text: string): LineData[] {
3636
return text.split("\n").map((line) => {
3737
const parts = line
3838
.trimEnd()
39-
.replace(/[^\p{L}\p{N}]/gu, " ")
39+
.replace(/[,""''"".]/gu, " ")
4040
.split(/\s+/)
4141
.filter((p) => p.length > 0);
4242
const tokens = parts
@@ -105,19 +105,21 @@ export function visualizeTextDiff(textA: string, textB: string) {
105105

106106
let hasDifference = false;
107107

108-
const checkTokens = (tokens: WordToken[] | undefined) => {
108+
const checkTokens = (tokens: WordToken[] | undefined, isRowA: boolean) => {
109109
if (!tokens) return false;
110110
for (const t of tokens) {
111111
if (!t.key) continue;
112112
const countA = freqA.get(t.key) || 0;
113113
const countB = freqB.get(t.key) || 0;
114-
if (countA !== countB) return true;
114+
if (isRowA ? countA > countB : countB > countA) {
115+
return true;
116+
}
115117
}
116118
return false;
117119
};
118120

119-
const diffA = checkTokens(lineRowA?.tokens);
120-
const diffB = checkTokens(lineRowB?.tokens);
121+
const diffA = checkTokens(lineRowA?.tokens, true);
122+
const diffB = checkTokens(lineRowB?.tokens, false);
121123

122124
const emptyA = !lineRowA || lineRowA.tokens.length === 0;
123125
const emptyB = !lineRowB || lineRowB.tokens.length === 0;

package-lock.json

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
},
2626
"devDependencies": {
2727
"@octokit/rest": "^21.0.2",
28-
"@types/html-to-text": "^9.0.4",
2928
"prettier": "3.6.2"
3029
}
3130
}

0 commit comments

Comments
 (0)