simpread icon indicating copy to clipboard operation
simpread copied to clipboard

捉个虫: 标注嵌入模式模板有点小毛病

Open CanoNandMacaroN opened this issue 4 years ago • 6 comments

  • https://github.com/Kenshin/simpread/discussions/2153#discussioncomment-2983977

  • 起因:

  • 今天打算学习一下标注嵌入模板的全部用途,结果到了最后一步块引用的时候始终复制不上Block ID,一度怀疑是插件的问题,排查半天发现没有人有这个问题,读了一下官方文档之后怀疑是ID不存在的问题,于是乎对比了一下两个标注模板,问题解决!

Xnip2022-10-05_04-17-05 Xnip2022-10-05_04-16-39

CanoNandMacaroN avatar Oct 04 '22 20:10 CanoNandMacaroN

哈,谢谢捉 🐛

你可以把模板放上来,我优化下官方的模板~

Kenshin avatar Oct 05 '22 03:10 Kenshin

哈,谢谢捉 🐛

你可以把模板放上来,我优化下官方的模板~

<%
let colors = [ '#B4D9FB', '#ffeb3b', '#a2e9f2', '#a1e0ff', '#a8ea68', '#ffb7da' ],
    color  = colors[ annote.color ];
if (unread.note && unread.title != unread.note) {
var filetitle = unread.note;
}
else {
var filetitle = unread.title;
}
let wikilinks = "[[SR" + unread.idx + "@" + filetitle + "|📄]]";
-%>
<% if (annote.note.startsWith("######")) { %>
<% 
let note = annote.note.slice(7);
-%>
###### <% if (note) { %><%- note %><% } else { %>{{an_text}}<% } %>
<% } else if (annote.note.startsWith("######")) { %>
<% 
let note = annote.note.slice(6);
-%>
###### <% if (note) { %><%- note %><% } else { %>{{an_text}}<% } %>
<% } else if (annote.note.startsWith("####")) { %>
<% 
let note = annote.note.slice(5);
-%>
#### <% if (note) { %><%- note %><% } else { %>{{an_text}}<% } %>
<% } else if (annote.note.startsWith("###")) { %>
<% 
let note = annote.note.slice(4);
-%>
### <% if (note) { %><%- note %><% } else { %>{{an_text}}<% } %>
<% } else { %>
> <%- wikilinks %> <mark style="background-color: <%= color %>">Highlights</mark> [🧷](<{{an_int_uri}}>) [🌐](<{{an_ext_uri}}>) {{#|an_tag| }}  
{{{html_format|>|{{an_html}}}}}
<% if (annote.refs) { -%>
{{> - 🔗|an_refs}}
<% } -%>
<% if (annote.note) { -%>
<% if (annote.note.startsWith("todo:") == false) { -%>
>  
> - 📝{{an_note}}

^sran-{{an_id}}
<% } else { -%>
<% 
let note = annote.note.slice(6);
-%> 
^sran-{{an_id}}

- [ ] <%- note %> #web ^srtask-{{an_id}}
<% } -%>
<% } else { %>
^sran-{{an_id}}
<% } -%>
<% } -%>

之前是换行问题导致的标注callout块分割不明确

CanoNandMacaroN avatar Oct 05 '22 05:10 CanoNandMacaroN

情况有所更新 https://github.com/Kenshin/simpread/issues/4751#issuecomment-1326374224

CanoNandMacaroN avatar Nov 24 '22 12:11 CanoNandMacaroN

使用callout块的模板留档

<%
let colors = [ '#B4D9FB', '#ffeb3b', '#a2e9f2', '#a1e0ff', '#a8ea68', '#ffb7da' ],
    color  = colors[ annote.color ];
let chls = [ 'srhl1', 'srhl2', 'srhl3', 'srhl4', 'srhl5', 'srhl6' ],
    chl  = chls[ annote.color ];
let iframeURI = "http://localhost:7026/unread/"+unread.idx+"#id="+annote.id
if (unread.note && unread.title != unread.note) {
var filetitle = unread.note;
}
else {
var filetitle = unread.title;
}
let wikilinks = "[[SR" + unread.idx + "@" + filetitle + "|📄]]";
-%>
<% if (annote.note.startsWith("######")) { %>
<% 
let note = annote.note.slice(7);
-%>
###### <% if (note) { %><%- note %><% } else { %>{{an_text}}<% } %>
<% } else if (annote.note.startsWith("######")) { %>
<% 
let note = annote.note.slice(6);
-%>
###### <% if (note) { %><%- note %><% } else { %>{{an_text}}<% } %>
<% } else if (annote.note.startsWith("####")) { %>
<% 
let note = annote.note.slice(5);
-%>
#### <% if (note) { %><%- note %><% } else { %>{{an_text}}<% } %>
<% } else if (annote.note.startsWith("###")) { %>
<% 
let note = annote.note.slice(4);
-%>
### <% if (note) { %><%- note %><% } else { %>{{an_text}}<% } %>
<% } else { %>
> [!<%= chl %>] <%- wikilinks %> <mark style="background-color: <%= color %>">Highlights</mark> [🧷](<<%= iframeURI %>>) [🌐](<{{an_ext_uri}}>) {{#|an_tag| }}  
{{{html_format|>|{{an_html}}}}}
<% if (annote.refs) { -%>
{{> - 🔗|an_refs}}
<% } -%>
<% if (annote.note) { -%>
<% if (annote.note.startsWith("todo:") == false && annote.note.startsWith("done:") == false) { -%>
>  
> - 📝{{an_note}}

^sran-{{an_id}}
<% } else { -%>
<% 
let note = annote.note.slice(6);
if (annote.note.startsWith("todo:")) {
  var taskStatus = " "; }
  else {
  var taskStatus = "x";
}
-%>
^sran-{{an_id}}

- [<%= taskStatus %>] <%- note %> #web ^srtask-{{an_id}}
<% } -%>
<% } else { -%>
^sran-{{an_id}}
<% } -%>
<% } -%>

CanoNandMacaroN avatar Nov 24 '22 12:11 CanoNandMacaroN

如果要使用callouts块标注,就会跟text transport插件冲突无法复制,只能通过手动输入块ID的方式来引用,目前无解,不过好在可以检索,并不是那么麻烦🤔 具体操作:依次输入![[^^后,复制粘贴块ID实现检索,效率上其实跟使用插件没什么区别。

CanoNandMacaroN avatar Nov 24 '22 15:11 CanoNandMacaroN

callout确实不能通过text transport复制。所以我的方法是用quicker写了个从callout里提取blockID的脚本。

1wingedangel avatar Nov 27 '22 07:11 1wingedangel