mirror of
https://github.com/panatgithub/AnkiHeadingSync.git
synced 2026-07-22 17:10:28 +00:00
中文: 补充 cardsInfo 读取与 deck 校验流程,让 marker 驱动的旧卡和本地状态漂移场景也能自愈迁移牌组;同时对标题末尾的 #标签 回跳做最小归一化,提升从 Anki 返回 Obsidian 标题定位的兼容性,并提交用于排查的查询脚本。 English: Add cardsInfo-backed deck verification so marker-backed existing notes and deck drift can self-heal during sync. Also normalize trailing heading tags in Obsidian backlinks to improve heading jump compatibility from Anki, and include the helper query scripts used for investigation.
39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
const http = require('http');
|
|
|
|
const invoke = (action, params = {}) => new Promise((resolve, reject) => {
|
|
const body = JSON.stringify({ action, version: 6, params });
|
|
const req = http.request('http://127.0.0.1:8765', {method: 'POST'}, res => {
|
|
let d = ''; res.on('data', c => d += c);
|
|
res.on('end', () => {
|
|
try {
|
|
const r = JSON.parse(d);
|
|
if (r.error) reject(new Error(r.error));
|
|
else resolve(r.result);
|
|
} catch (e) { reject(e); }
|
|
});
|
|
});
|
|
req.on('error', reject);
|
|
req.write(body); req.end();
|
|
});
|
|
|
|
(async () => {
|
|
try {
|
|
const notes = await invoke('notesInfo', { notes: [1755676734055] });
|
|
if (!notes || notes.length === 0) {
|
|
console.log('No note found for ID 1755676734055');
|
|
return;
|
|
}
|
|
const note = notes[0];
|
|
const front = note.fields.正面 ? note.fields.正面.value : '';
|
|
const back = note.fields.背面 ? note.fields.背面.value : '';
|
|
|
|
console.log('--- Front (First 300) ---');
|
|
console.log(front.substring(0, 300));
|
|
console.log('\n--- Back (First 500) ---');
|
|
console.log(back.substring(0, 500));
|
|
console.log('\n--- Check String ---');
|
|
console.log('Contains "Open in Obsidian":', back.includes('Open in Obsidian'));
|
|
} catch (e) {
|
|
console.error('Error:', e.message);
|
|
}
|
|
})();
|