Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions src/chrome/content/journal.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,26 @@ Journal = {
return newAuthorList;
},

decodeHTMLEntities(text) {
if (typeof text !== 'string' || !text) return text;

// 实体映射表(可扩展)
const entities = {
'&': '&',
'&lt;': '<',
'&gt;': '>',
'&quot;': '"',
'&#39;': "'",
'&nbsp;': ' ',
// 添加其他常见实体...
};

// 一次性替换所有已知实体
return text.replace(/&(amp|lt|gt|quot|#39|nbsp);/g, (match, entity) => {
return entities[match] || match;
});
},

generateDate (date) {
if (!date) {
return null;
Expand Down Expand Up @@ -59,14 +79,14 @@ Journal = {
}
})
.then(dataJson => {
var Title = Utilities.safeGetFromJson(dataJson, ["title"]);
var Title = this.decodeHTMLEntities(Utilities.safeGetFromJson(dataJson, ["title"]));
var Authors = this.generateAuthors(Utilities.safeGetFromJson(dataJson, ["author"]));
var Publication = Utilities.safeGetFromJson(dataJson, ["container-title"]);
var Publication = this.decodeHTMLEntities(Utilities.safeGetFromJson(dataJson, ["container-title"]));
var Volume = Utilities.safeGetFromJson(dataJson, ["volume"]);
var Issue = Utilities.safeGetFromJson(dataJson, ["issue"]);
var Pages = Utilities.safeGetFromJson(dataJson, ["page"]);
var PublishDate = this.generateDate(Utilities.safeGetFromJson(dataJson, ["published", "date-parts"]));
var JournalAbbr = Utilities.safeGetFromJson(dataJson, ["container-title-short"]);
var JournalAbbr = this.decodeHTMLEntities(Utilities.safeGetFromJson(dataJson, ["container-title-short"]));
var Language = Utilities.safeGetFromJson(dataJson, ["language"]);
return {
"Title": Title ? Title : "",
Expand Down Expand Up @@ -100,4 +120,4 @@ Journal = {
await item.saveTx();
return 0;
}
}
}