",
};
diff --git a/src/modules/sync/api.ts b/src/modules/sync/api.ts
index 3889c03..dba90a1 100644
--- a/src/modules/sync/api.ts
+++ b/src/modules/sync/api.ts
@@ -1,6 +1,7 @@
import YAML = require("yamljs");
import { clearPref, getPref, setPref } from "../../utils/prefs";
import { getNoteLinkParams } from "../../utils/link";
+import { config } from "../../../package.json";
export {
getRelatedNoteIds,
@@ -91,7 +92,7 @@ function getNoteStatus(noteId: number) {
const metaRegex = /"?data-schema-version"?="[0-9]*">/;
const match = fullContent?.match(metaRegex);
if (!match || match.length == 0) {
- ret.meta = '
';
+ ret.meta = `
`;
ret.content = fullContent || "";
return ret;
}
diff --git a/src/utils/note.ts b/src/utils/note.ts
index e520099..7443623 100644
--- a/src/utils/note.ts
+++ b/src/utils/note.ts
@@ -3,6 +3,7 @@ import katex from "katex";
import { getEditorInstance, getPositionAtLine, insert } from "./editor";
import { getItemDataURL } from "./str";
import { showHint } from "./hint";
+import { config } from "../../package.json";
export {
renderNoteHTML,
@@ -19,12 +20,10 @@ export {
};
function parseHTMLLines(html: string): string[] {
- let containerIndex = html.search(/data-schema-version="[0-9]*">/g);
- if (containerIndex != -1) {
- html = html.substring(
- containerIndex + 'data-schema-version="8">'.length,
- html.length - "
".length
- );
+ // Remove container with one of the attrs named data-schema-version if exists
+ if (html.includes("data-schema-version")) {
+ html = html.replace(/
]*data-schema-version[^>]*>/, "");
+ html = html.replace(/<\/div>/, "");
}
let noteLines = html.split("\n").filter((e) => e);
@@ -125,11 +124,17 @@ async function setLinesToNote(note: Zotero.Item, lines: string[]) {
let noteText: string = note.getNote();
let containerIndex = noteText.search(/data-schema-version="[0-9]*/g);
if (containerIndex === -1) {
- note.setNote(`
${lines.join("\n")}
`);
+ note.setNote(
+ `
${lines.join(
+ "\n"
+ )}
`
+ );
} else {
let noteHead = noteText.substring(0, containerIndex);
note.setNote(
- `${noteHead}data-schema-version="8">${lines.join("\n")}
`
+ `${noteHead}data-schema-version="${
+ config.dataSchemaVersion
+ }">${lines.join("\n")}