chrisgrieser / alfred-bibtex-citation-picker

Citation picker & lightweight reference manager for BibTeX files, via Alfred.
MIT License
137 stars 8 forks source link

Create a new bibliography copy styple #38

Closed jxpeng98 closed 1 year ago

jxpeng98 commented 1 year ago

Hi,

I follow your generate_temp_bib.sh to create a new style that only generates the inline citations. In generate_temp_bib.sh, if you press the button cmd+option+enter, it will return:

Wang, Z., Chen, J., & Zhao, X. (2020). Risk Information Disclosure and Bank Soundness: Does Regulation Matter? Evidence from China*. International Review of Finance, 20(4), 973–981. https://doi.org/10.1111/irfi.12244

In generate_temp_citation.sh, it will return:

Wang, Chen, & Zhao (2020)

You may assign another hotkey combination for this citation style.

chrisgrieser commented 1 year ago

hi, thanks for the PR!

However, I am not really what the purpose of this feature is. The intended workflow for using pandoc and markdown is to insert pandoc citations, and to run pandoc on the final document once. The feature to paste the full bibliography is mostly a convenience feature for sending a one-off reference to peers via mail.

How would your proposed feature be more useful than just inserting pandoc citations and then running pandoc on the document?

jxpeng98 commented 1 year ago

Hi,

Many thanks for your reply!

Recently, I am trying to use slidev to create academic slides. I need to insert some citations in the slides, however, the project cannot render the citekey and generate a reference list via pandoc-citeproc. That is why I find use Alfred to generate the citation to complete this requirement.

It will be like this:

image

Thanks!

chrisgrieser commented 1 year ago

I see, that makes sense, yeah. However, I think your problem can be solved in a simpler way on your end:

You can use pandoc with the options --to=markdown-citations --metadata=suppress-bibliography:true to use pandoc solely as a citation resolver, (while keeping the markdown as input and output format).

So by using a command like this:

pandoc --citeproc --bibliography="$HOME/.pandoc/bibliography.bib" input.md -o output.md --to=markdown-citations --metadata="suppress-bibliography:true"

you will get an output file where all pandoc citations are resolved correctly, but where nothing else is changed, allowing you to use slidev as usual.

As opposed to resolving citations with the Alfred workflow, this has the advantage that your original document is still pure pandoc markdown, meaning that as opposed to resolving citations, your editor can still apply syntax highlighting for the citations, and you can still switch citation style later on with the --csl option from pandoc

jxpeng98 commented 1 year ago

I appreciate your suggestion.

But the performance could be better.

The --citeproc will ignore the YAML front matter and also disorganise the HTML code. For example, the original code is:

<div class="pt-12">
  <span @click="$slidev.nav.next" class="px-2 py-1 rounded cursor-pointer" hover="bg-white bg-opacity-10">
    Press Space for next page <carbon:arrow-right class="inline"/>
  </span>
</div>

After I apply pandoc --citeproc, the HTML division has changed to

::: pt-12
\<span (**click?**)="\$slidev.nav.next" class="px-2 py-1 rounded
cursor-pointer" hover="bg-white bg-opacity-10"\> Press Space for next
page `<carbon:arrow-right class="inline"/>`{=html} `</span>`{=html}
:::

So I think the best way to keep the pure markdown file is only to insert the reference rather than use --citeproc to render the file.

chrisgrieser commented 1 year ago

Hmm, I see. Nevertheless, I am still somewhat hesitant about adding a feature whose sole purpose appears to be to deal with the shortcoming of another app.

I assume for the particular case of the unintended html conversion, you can probably prevent that as well with some pandoc option. Could you maybe try asking around in the pandoc google group how to prevent the html conversions? If that also yields no useful help, I'll consider merging this as a feature.

jxpeng98 commented 1 year ago

Understand!

Thanks for your link. I will get more information from different resources and update you later.

jxpeng98 commented 1 year ago

Hi,

I find an easy way to use pandoc and --citeproc to render the markdown file and keep the content unchanged. It should generate an intermediate json file.

pandoc --citeproc input.md -o intermediate.json -s
pandoc intermediate.json -t gfm -o output.md -s

I try different output formats, but it can only use the gfm. Other formats will ignore the YAML front matter. You also need to use ------------------------ as the pagebreak.

The above process cannot handle the HTML code very well, but it can be used for simple academic slides.