jgm / pandoc

Universal markup converter
https://pandoc.org
Other
33.21k stars 3.3k forks source link

Org-ref citation support #5710

Open sati-bodhi opened 4 years ago

sati-bodhi commented 4 years ago

Does Pandoc currently support the rendering of Org-Ref style citations? The documentation over here seems to suggest it does; but I was not able to get it working correctly.

Org Citations

[@徐復觀YinYangWuXingJiQiYouGuanWenXianDeYanJiu1969{555-563}];cite:陳鼓應YiChuanYuDaoJiaSiXiang1994

(saved as citation_issues.org)

To be rendered as:

徐復觀〈陰陽五行及其有關文獻的研究〉,收入《中國人性論史》,頁555-563。陳鼓應,《易傳與道家思想》(台北:臺灣商務印書館,1994年)。

CSL:

https://gist.github.com/sati-bodhi/31dd24dd280c88d51908

Bibtex:

@book{陳鼓應YiChuanYuDaoJiaSiXiang1994,
  langid = {pinyin},
  location = {{台北}},
  title = {易傳與道家思想},
  isbn = {978-957-05-0994-6},
  pagetotal = {382},
  publisher = {{臺灣商務印書館}},
  date = {1994},
  author = {陳鼓應},
  eprinttype = {googlebooks}
}

@incollection{徐復觀YinYangWuXingJiQiYouGuanWenXianDeYanJiu1969,
  location = {{臺北}},
  title = {陰陽五行及其有關文獻的研究},
  booktitle = {中國人性論史(先秦篇)},
  publisher = {{商務}},
  date = {1969},
  pages = {509-587},
  author = {{徐復觀}}
}

(saved as thesis.bib)

Pandoc:

pandoc -F pandoc-citeproc --csl=humanities-chinese.csl --bibliography=thesis.bib -f org -t odt -o citation_issues.odt citation_issues.org

Result:

徐復觀,〈陰陽五行及其有關文獻的研究〉,收入《中國人性論史(先秦篇)》(臺北:商務,1969),頁555–563;cite:陳鼓應YiChuanYuDaoJiaSiXiang1994。

Native Pandoc syntax works but org-ref syntax doesn't.

mb21 commented 4 years ago

What's your pandoc version?

sati-bodhi commented 4 years ago

pandoc 2.7.3 Compiled with pandoc-types 1.17.5.4, texmath 0.11.2.2, skylighting 0.8.1

jgm commented 4 years ago

@tarleb is the expert on this and might be able to comment.

tarleb commented 4 years ago

The problem stems from the semicolon between the citations: pandoc seems to mishandle the fullwidth semicolon (U+FF1B) in your text. It works if one uses a normal semicolon (U+003B) instead.

We could consider to treat more punctuation characters as "special characters" in the parser, which would resolve this. I will take a look into this.

mb21 commented 4 years ago

Yes, if it's a common thing in Asian languages to use the full-width semicolon. Otherwise I don't think we should get into the hole of considering similar unicode chars for all the chars in our syntax.

sati-bodhi commented 4 years ago

Full width punctuation is very common at least within the Chinese and Japanese context, partly because words in these two languages are not separated by spaces. For example:

This is a sentence; This is another sentence. これは文です。これは別の文です。 這是一句話;這是另一句話。

Adding a full-stop at the back of the syntax also breaks the code. cite:陳鼓應YiChuanYuDaoJiaSiXiang1994。

tarleb commented 4 years ago

From what I can tell, org-ref cites are special in that they do not conform to the usual emphasis conditions checked by org-mode.

Here are some examples and how they are translated to LaTeX by org-ref:

cite:陳鼓應YiChuanYuDaoJiaSiXiang1994
<cite:陳鼓應YiChuanYuDaoJiaSiXiang1994>
;citep:陳鼓應YiChuanYuDaoJiaSiXiang1994
#citep:陳鼓應YiChuanYuDaoJiaSiXiang1994
$citep:陳鼓應YiChuanYuDaoJiaSiXiang1994
%citep:陳鼓應YiChuanYuDaoJiaSiXiang1994

output

\cite{陳鼓應YiChuanYuDaoJiaSiXiang1994}
\cite{陳鼓應YiChuanYuDaoJiaSiXiang1994}
;\citep{陳鼓應YiChuanYuDaoJiaSiXiang1994}
\#\citep{陳鼓應YiChuanYuDaoJiaSiXiang1994}
\$citep:陳鼓應YiChuanYuDaoJiaSiXiang1994
\%citep:陳鼓應YiChuanYuDaoJiaSiXiang1994

Seems like it is mostly breaking at word boundaries, although I'm a bit confused about $ and %. I'll have to read the code.

sati-bodhi commented 4 years ago

Citations with locator also didn't resolve well.

[[cite:陳鼓應YiChuanYuDaoJiaSiXiang1994][55-100]]

This one got interpreted as a simple link:

55-100

sati-bodhi commented 4 years ago

Another weird bug that might be a separate issue: The Pandoc interpreter renders book citations with an extra text term in between title and publisher.

陳鼓應,《易傳與道家思想》。收入台北:臺灣商務印書館,1994年。

If we use the same csl file on Zotero or the Visual CSL Editor, the text term should not be there:

圖片

Add the following csl-data.json to Example citations → Advanced → Add new reference to testify the issue.

[
  {"id":"陳鼓應YiChuanYuDaoJiaSiXiang1994","type":"book","title":"易傳與道家思想","publisher":"臺灣商務印書館","number-of-pages":"382","source":"Google Books","ISBN":"978-957-05-0994-6","language":"zh-TW","author":[{"literal":"陳鼓應"}],"issued":{"date-parts":[[1994]]},"publisher-place":"台北"}
]
bdarcus commented 2 years ago

Should be superceded by #7329?