hans / obsidian-citation-plugin

Obsidian plugin which integrates your academic reference manager with the Obsidian editor. Search your references from within Obsidian and automatically create and reference literature notes for papers and books.
MIT License
1.04k stars 77 forks source link

[Bug] The plugin failed to correctly translate the note field of BibTex items. #171

Open yangfurong opened 2 years ago

yangfurong commented 2 years ago

Describe the bug

The plugin failed to correctly translate the note field of BibTex items if there are multiple href in one line of the note field.

For example, I have the bibtex item as shown below.


@article{huang_IndepthStudyLTE_2013,
  title = {An In-Depth Study of {{LTE}}: Effect of Network Protocol and Application Behavior on Performance},
  shorttitle = {An In-Depth Study of {{LTE}}},
  author = {Huang, Junxian and Qian, Feng and Guo, Yihua and Zhou, Yuanyuan and Xu, Qiang and Mao, Z. Morley and Sen, Subhabrata and Spatscheck, Oliver},
  year = {2013},
  month = sep,
  journal = {ACM SIGCOMM Computer Communication Review},
  volume = {43},
  number = {4},
  pages = {363--374},
  note = {\section{Annotations\\
(5/10/2022, 6:59:51 PM)}

\par
``However, the interactions among applications, network transport protocol, and the radio layer still remain unexplored.'' |Open PDF, \href{zotero://open-pdf/library/items/8SU8CCQA?page=0&annotation=EZFZEMQV}{Open PDF}| (Huang et al., 2013, p. 363 |Open item, \href{zotero://select/library/items/L2KWDK96}{Open item}|)
\par
``We observed that LTE has significantly shorter state promotion delays and lower RTTs than those of 3G networks.'' |Open PDF, \href{zotero://open-pdf/library/items/8SU8CCQA?page=0&annotation=WD3P2JKD}{Open PDF}| (Huang et al., 2013, p. 363 |Open item, \href{zotero://select/library/items/L2KWDK96}{Open item}|)
\par
(Huang et al., 2013, p. 363 |Open item, \href{zotero://select/library/items/L2KWDK96}{Open item}|) test
\par
(Go to the note, \href{zotero://select/library/items/XMZP86RD}{Go to note})\\
..................................
\par
\section{Manually Generated Notes}

\par
This is a reference to (Atxutegi et al., 2018 |Open item, \href{zotero://select/library/items/8FC6JVQ6}{Open item}|)
\par
(Atxutegi et al., 2018 |Open item, \href{zotero://select/library/items/8FC6JVQ6}{Open item}|; Croitoru et al., 2015 |Open item, \href{zotero://select/library/items/IR9GYRYW}{Open item}|; Dong et al., 2018 |Open item, \href{zotero://select/library/items/BGMMKVIF}{Open item}|)
\par
\href{https://bing.com}{aaa}
\par
(Go to the note, \href{zotero://select/library/items/Y4J279RR}{Go to note})\\
..................................}
}

If I use Citation to generate a note in Obsidian, the result is as follows.

---
title: An in-depth study of LTE: Effect of network protocol and application behavior on performance
authors: Junxian Huang, Feng Qian, Yihua Guo, Yuanyuan Zhou, Qiang Xu, Z. Morley Mao, Subhabrata Sen, Oliver Spatscheck
year: 2013
---
<h1>Annotations
 (5/10/2022, 6:59:51 PM)</h1> 

“However, the interactions among applications, network transport protocol, and the radio layer still remain unexplored.” |Open PDF, [Link](zotero://open-pdf/library/items/8SU8CCQA?page=0&annotation=EZFZEMQV| (Huang et al., 2013, p. 363 |Open item, zotero://select/library/items/L2KWDK96|) )

“We observed that LTE has significantly shorter state promotion delays and lower RTTs than those of 3G networks.” |Open PDF, [Link](zotero://open-pdf/library/items/8SU8CCQA?page=0&annotation=WD3P2JKD| (Huang et al., 2013, p. 363 |Open item, zotero://select/library/items/L2KWDK96|) )

(Huang et al., 2013, p. 363 |Open item, [Link](zotero://select/library/items/L2KWDK96|) test )

(Go to the note, [Link](zotero://select/library/items/XMZP86RD))
 .................................. 

<h1>Manually Generated Notes</h1> 

This is a reference to (Atxutegi et al., 2018 |Open item, [Link](zotero://select/library/items/8FC6JVQ6|) )

(Atxutegi et al., 2018 |Open item, [Link](zotero://select/library/items/8FC6JVQ6|; Croitoru et al., 2015 |Open item, zotero://select/library/items/IR9GYRYW|; Dong et al., 2018 |Open item, zotero://select/library/items/BGMMKVIF|) )

https://bing.com 

(Go to the note, [Link](zotero://select/library/items/Y4J279RR))
 ..................................

To Reproduce Steps to reproduce the behavior:

  1. Create a bibtex file only contains the above bibtex item.
  2. Go to Obsidian Settings -> Citations , to change the database path the bibtex file.
  3. Open a blank note in Obsidian
  4. Ctrl+P and enter Citations in the textbox
  5. Select Citations: open literature note
  6. Done

Console output Please open the Obsidian developer console (Ctrl+Shift+I). Click anywhere in the console and force reload Obsidian by typing Ctrl+R. Then reproduce the issue you're describing. Please include any relevant error messages that appear in the console in your report here.

No relevant error was reported.

Expected behavior Those lines that have multiple href links should be able to have multiple links in the generated markdown file.

Screenshots If applicable, add screenshots to help explain your problem.

Platform

Additional context Add any other context about the problem here.

yangfurong commented 2 years ago

The problem should be relevant to this function in src/type.ts

  public get note(): string {
    return this._note
      ?.map((el) => el.replace(/(zotero:\/\/.+)/g, '[Link]($1)'))
      .join('\n\n');
  }