typora-issues icon indicating copy to clipboard operation
typora-issues copied to clipboard

Support academic referencing in the future?

Open synergico opened this issue 7 years ago • 40 comments

Hi, I know this is kinda far fetching, but I think it could be awesome if Typora supports referencing by using something like '@' to mention a source, by connecting to something like Endnote, Zotero or BibRef? It could win a lot of customers like student or researcher Just planting an idea here :), cause I enjoy writing with Typora everyday. Cheers, Tri

synergico avatar Sep 16 '17 12:09 synergico

if Typora could do this, it would be a New Emacs, at lest, a new org-mode.

On Sat, Sep 16, 2017 at 8:20 PM, synergico [email protected] wrote:

Hi, I know this is kinda far fetching, but I think it could be awesome if Typora supports referencing by using something like '@' to mention a source, by connecting to something like Endnote, Zotero or BibRef? It could win a lot of customer like student or researcher Just planting an idea here :), cause I enjoy writing with Typora everyday. Cheers, Tri

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/typora/typora-issues/issues/912, or mute the thread https://github.com/notifications/unsubscribe-auth/AegYqkYl_LpT590rK37xlJ0RxnHx-b6Uks5si70jgaJpZM4PZzWK .

x7x7 avatar Sep 17 '17 03:09 x7x7

related: #66

nimirea avatar Sep 21 '17 13:09 nimirea

I'd love this feature as well! I really like writing in markdown, but writing scientific papers is still a pain and requires a lot of fiddling around. If you could somehow nail this with typora, I'd be willing to throw a lot of money in your direction! 😄 I'm looking for a markdown editor that can do this for quite a while.

sgoehre avatar Sep 24 '17 12:09 sgoehre

By support, it means

  • support syntax highlight (#294)
  • support auto-complete (#66 )

Is there any other kind of support I missed?

abnerlee avatar Jan 19 '18 17:01 abnerlee

Op of #66 here, I think you have it covered

jhrmnn avatar Jan 19 '18 22:01 jhrmnn

@azag0 Pardon my noob-ness, how do I start referencing? Would you point me to a quick tutorial? Thank you very much! Is it possible to use it with Zotero?

synergico avatar Jan 28 '18 12:01 synergico

@abnerlee Adding my name to this request -- for me, I'm particularly looking for pandoc-citeproc support (and relatedly, I'd also love to be able to use pandoc to export to LaTeX PDF directly from within Typora).

tweedyf avatar Jan 31 '18 15:01 tweedyf

@abnerlee In addition to syntax-highlighting and auto-completion, one would also want to have the references correctly displayed in exported HTML and PDF.

So one could add to the list:

  • list of references in exported files
  • links between references and item in list of references in exported files
  • choosing a citation format, e.g. with a CSL file

if Typora supports referencing by using something like '@' to mention a source, by connecting to something like Endnote, Zotero or BibRef

How about referencing from a bibtex file? Most reference managers can export the library that way.

fhchl avatar Feb 06 '18 10:02 fhchl

An example how it works in Scrivener with pandoc, a reference style (CSL file) and an bibtex (my.bib) export out of Bookends as the reference manager: https://github.com/iandol/scrivomatic https://www.rousette.org.uk/archives/bookends-and-pandoc/

If I choose Typora, and I would love to, writing a thesis, it is necessary to have direct support. Else I need to export my research paper out of Typora to Word and use Bookends in Word parsing the citation entries. It is an option, but increases the time I need for my adacemic workflow.

admin-teametry avatar Mar 19 '18 11:03 admin-teametry

We still need official support for this; I suggest that Typora looks for a .bib file in the same directory af the current .md file as default, and custom path .bib files to be added in the YAML header.

However until we (hopefully) get this, here is a workaround for Mac and Alfred users:

https://www.alfredforum.com/topic/11572-autocomplete-words-from-a-textfile/?tab=comments#comment-60512

gandalfsaxe avatar Jun 12 '18 11:06 gandalfsaxe

Btw if one uses pandoc to convert instead of just exporting from within Typora, you can choose a csl file using in the header e.g. csl: "chicago-author-date.csl" where in this case the csl file is in the same folder.

gandalfsaxe avatar Jun 12 '18 11:06 gandalfsaxe

This would be great! Love using Typora, but i just got some flak for not referencing properly. Might write a simple regex-script to do this myself, but would definitely prefer something integrated.

Peder2911 avatar Oct 10 '18 14:10 Peder2911

You can use Pandoc to convert your Markdown file with citations to a LaTeX, PDF or Markdown where your citation markup is replaced by citations and a list of references in a style defined in a csl-file. Raphael Kabo covers that approach in detail at his blog.

What I would like to see is live rendering support for Markdown citations in Typora's preview mode. It works in Atom Editor with Markdown Preview Plus and pandoc as render backend enabled.

alexandergogl avatar Nov 25 '18 00:11 alexandergogl

I think a simple-to-implement and helpful first step would be if Typora would support pandoc's --bibliography argument. For instance, pandoc --bibliography references.bib myfile.md -o myfile.docx would convert a markdown into a Word file using and converting the references in the .bibfile.

So there could be new options for exporting in Typora: Export > Word (with references) and Export > PDF (with references)

nheeren avatar Mar 15 '19 07:03 nheeren

Note: this refers to the issue of syntax highlighting (#294), but as this issue is closed, posted it here as well. I got the highlighting working by inserting some javascript in the console. Steps to replicate:

First: Create a file named base.user.css in /Users/username/Library/Application Support/abnerworks.Typora/themes/, and add the following code [with the highlight color of your choice]:

.blue {
  color: #005ce6
}
  1. Activate Debugging:
    • Typora -> Preference... -> Security -> check Enable Debug
    • OR: Help -> Enable Debugging
  2. Open the debugging editor by right clicking some text and selecting Inspect Element
  3. Go to the console tab and insert the following code:
 $(document).ready(function(){
     $("#write").html(function(_, html){
        return html.replace(/(\@\w\S+)/g, '<span class="blue">$1</span>');   
     });
 });

This should give something like this (with Night theme enabled): Screenshot 2019-03-21 at 21 21 07

A live version of the code can be found here http://jsfiddle.net/drckx/z3e10bwa/ [based on css-tricks post]

Now, some more practical questions, does anybody know how to:

  1. Enable this automatically (without the need to go through the console) ?
  2. Refresh regularly so that newly typed @reference items also get coloured?
  3. Also: optimise the RegEx expression /(\@\w\S+)/g so that trailing points or brackets don't get coloured?
    • Edit: with citations in the format @author_title_YEAR it seems to work with /(\@\w\S+\d\d\d\d)/g

floriandierickx avatar Mar 21 '19 20:03 floriandierickx

One step further in getting forward with point 1. :

It seems that injecting a script after line 218 in index.html does the trick of colouring the references when opening Typora, but it messes some lists up (depending on the location, before or after line 219, also MathJax) and it seems writing gets altered as well [shifting pointer, etc..]

To reproduce:

  1. Create a new javascript-file, for example: /Applications/Typora.app/Contents/Resources/TypeMark/app/colour.js:

Fill in with:

$(document).ready(function(){ $("#write").html(function(_, html){ return html.replace(/(\@\w\S+\d\d\d\d)/g, '<span class="blue">$1</span>'); }); });
  1. Edit the index.html file in /Applications/Typora.app/Contents/Resources/TypeMark:

Add the following on line 220:

<script src="./app/colour.js" aria-hidden="true" defer></script>

floriandierickx avatar Mar 21 '19 23:03 floriandierickx

Update on syntax highlighting: I managed to get live syntax highlighting for references in the format [@citekey; @citekey; ...] or [@citekey] working. It is not yet able to differentiate @citekeys that are written without square brackets. If you have any idea how to solve this, please give a shout!

How to:

  1. Change Typora.app/Contents/Resources/Typemark/app/main.js (after reformat of code and afterwards using uglyfyjs to minify):
    • See gist of new main.js and gist with diff between old and new file.
    • Regex used (can be checked at regex101):
/^(?:^|[ ;\[-])\@\w\S+([^\]\s]*)/

and

/^(?:^|[ ;\[-])(\@|\u0040|\uFE6B|\uFF20|\u0040)\w\S+([^\]\s]*)/
  1. Add css class to color citations in Typora.app/Contents/Resources/Typemark/style/base.css
.md-citation {
color: #53c3fc;
opacity: .8;
font-family: monospace;
font-family: var(--monospace)
}

This should render the following (also while typing): Screenshot 2019-04-06 at 13 31 56 As you can see it is not yet ideal, but at least the citekeys in square brackets get recognised, also when there are multiple citekeys between the brackets. I tried a bunch of other regex expressions, but none was able to capture the @citekeys without brackets. For a list of regex codes I tried, see this gist. If somebody has any clue on how to optimise the regex expressions (both of citation and ut.citation_ex), give a shout and/or tryout and let me/us know!

floriandierickx avatar Apr 06 '19 12:04 floriandierickx

@floriandierickx Which Markdown spec is using syntax [@citekey] for references?

abnerlee avatar Apr 18 '19 14:04 abnerlee

It is Pandoc markdown citations, processed by pandoc-citeproc. A lot of researchers use this markdown-flavor to convert research documents [in Pandoc markdown or RMarkdown - from what I know they are basically the same, except that RMarkdown allows integration of R-code inside and is specifically tailored to be used in RStudio] to doc(x), latex or pdf. My setup (and I guess a lot of others) is using Zotero from @dstillman and co. for citations, Zotero BetterBibTex from @retorquere to maintain a clean .bib file, and markdown and pandoc to convert to pdf or other formats. A more 'latex-hardcore' alternative could be to use JabRef for citation management (in which case you don't need Zotero BetterBibTex), but the rest of the workstream setup would be the same I guess. They (Zotero, BetterBibtex, JabRef, markdown, pandoc) are all solid and very lively and well-maintained open source projects, used by a lot of researchers. I had already quite some fruitful exchanges with @retorquere on the development of Zotero BetterBibTex, and he helped me (and others) a lot to all have a nicely working research setup.

What your project is bringing to all this (I am currently using Atom with some tweaks to write), is that it would be much more pleasant to work and look at the text, so I hope you're considering integrating - to start with - citation syntax highlighting! And as @nheeren mentioned, another not-too-difficult implementation could be to integrate Pandoc in the features to convert markdown to other formats.

A little note: apart from citation formats such as [@citekey], [@citekey1; @citekey2], [see @citekey1, pp. 33-35; also @citekey2, chap. 1], [-@citekey], ... , also the usage of @citekey is used to integrate an in-text citation that will render as "...which has been proven by Steffen et al. (2012) and...". For this I didn't find a suitable working regex expression yet, and the regex that I implemented now is specifically tailored to citations in the format @lowcasetext_lowcasetext_*four digits*, as I have set it up like that in BetterBibTex. A better regex would be one that includes anything after the @until there is a ., , ;,? or another character that can be expected after a word or citation in a text, or - for the [@citekey, .....] variant - something to capture anything between [@ and ].

floriandierickx avatar Apr 18 '19 16:04 floriandierickx

While BBT primarily does BibTeX (which is unsurprising given its name), it also generates pandoc-friendly csl-json and csl-yaml, and provides an integration point for editors that want to provide cite as you write. The latter allows searching in Zotero via a simple HTTP API and outputs to the caller information about the reference -- currently various ways to decorate the citation key, but also fully rendered citations/bibliography entries, others (and more can be added if there's a good use-case)

retorquere avatar Apr 18 '19 20:04 retorquere

Anyone still waiting for citation support in Typora might want to check out the open source markdown editor Zettlr: https://www.zettlr.com/.

marcusyoung avatar Feb 14 '20 23:02 marcusyoung

I tried to use Zettlr, but its just so heavy on the eyes.

ben-xD avatar May 28 '20 10:05 ben-xD

Any updates on this?

AhmedThahir66 avatar Jul 12 '20 12:07 AhmedThahir66

I tried to use Zettlr, but its just so heavy on the eyes.

Agreed... the writing experience isn't as polished as typora.

AhmedThahir66 avatar Jul 12 '20 12:07 AhmedThahir66

Any update on the addition of bibliography support?

phisanti avatar Sep 18 '20 14:09 phisanti

It seems supporting citation is similar to supporting Latex equations - that is how Zettlr does it.

chonuchan avatar Sep 28 '20 11:09 chonuchan

It seems supporting citation is similar to supporting Latex equations - that is how Zettlr does it.

You mean, that's a "short-cut" to make it work, or are you proposing an implementation for the developer?

phisanti avatar Oct 02 '20 15:10 phisanti

Why not add support for syntax like Pandoc does? You could specify the path to the .bib file somewhere, maybe in the YAML header, and then in the text simply cite as [@2020AuthorShorttitle;@2019Author2Shorttitle2], the key recognition syntax being "[@". This way it would still be compatible with pandoc and would still allow for those workflows without changing anything.

leowill01 avatar Oct 02 '20 19:10 leowill01

Would love that feature as well! For example, like @leowill01 proposed above. This way it would also match the way you use academic citation in an editor like VS Code or Sublime.

maxfrischknecht avatar Feb 02 '21 11:02 maxfrischknecht

any updates on this one ?

ghost avatar Mar 25 '21 00:03 ghost