Skip to content

[Bug] 编写模板时,使用插件提供的API annotations2html提取注释到笔记中,会将下划线类型的注释改为高亮类型。 #1426

@zhikaiyici

Description

@zhikaiyici

Is there an existing issue for this?

  • I have searched the existing issues

Are you using the latest Zotero and the latest plugin?

  • I have confirmed I'm using the latest Zotero and the latest plugin

Environment

  • OS: Windows 11 24H2
  • Zotero Version: 7.0.22
  • Plugin Version: 2.5.5

Describe the bug

复现步骤:

  1. 在zotero中添加下划线类型的注释。
  2. 使用笔记模板生成笔记。
  3. 在笔记编辑页面显示注释颜色,underline类型的注释变成了highlight。

不使用annotations2html,使用Zotero.EditorInstanceUtilities.serializeAnnotations([{ ...(await Zotero.Annotations.toJSON(annoItem)), ...{ attachmentItemID: annoItem.parentID }}]);则无此问题。

可使用以下模板测试:

# This template is specifically for importing/sharing, using better 
# notes 'import from clipboard': copy the content and
# goto Zotero menu bar, click Tools->New Template from Clipboard.  
# Do not copy-paste this to better notes template editor directly.
name: "[item]Test for annotation extraction"
zoteroVersion: "7.0.22"
pluginVersion: "2.5.5"
savedAt: "2025-08-07T07:23:56.917Z"
content: |-
  ${{
      const attachments = Zotero.Items.get(topItem.getAttachments()).filter((i) => i.isPDFAttachment() || i.isSnapshotAttachment() || i.isEPUBAttachment());
      let annots = attachments[0].getAnnotations();
      let result = "";
      for (let annoItem of annots) {
          const res = Zotero.EditorInstanceUtilities.serializeAnnotations([{
              ...(await Zotero.Annotations.toJSON(annoItem)), ...{ attachmentItemID: annoItem.parentID }
          }]);
          result += "<b>zotero API</b>" + res.html;
          
          const htmlContent = await Zotero.BetterNotes.api.convert.annotations2html(
              [annoItem], 
              {
                  noteItem: targetNoteItem,
                  ignoreComment: false
              }
          );
          result += "<b>better notes API</b>" + htmlContent;
  
      }
      return result;
  }}$
2025-08-07.153857.mp4

Debug Output

log.txt

Anything else?

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions