typora / typora-issues

Bugs, suggestions or free discussions about the minimal markdown editor — Typora
https://typora.io
1.53k stars 56 forks source link

Support academic referencing in the future? #912

Open synergico opened 7 years ago

synergico commented 7 years ago

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

x7x7 commented 7 years ago

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 notifications@github.com 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 .

nimirea commented 7 years ago

related: #66

sgoehre commented 7 years ago

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.

abnerlee commented 6 years ago

By support, it means

Is there any other kind of support I missed?

jhrmnn commented 6 years ago

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

synergico commented 6 years ago

@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?

tweedyf commented 6 years ago

@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).

fhchl commented 6 years ago

@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:

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.

admin-teametry commented 6 years ago

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.

gandalfsaxe commented 6 years ago

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 commented 6 years ago

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.

Peder2911 commented 6 years ago

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.

alexandergogl commented 5 years ago

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.

nheeren commented 5 years ago

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)

floriandierickx commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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]*)/
  2. 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!

abnerlee commented 5 years ago

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

floriandierickx commented 5 years ago

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]`.

retorquere commented 5 years ago

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)

marcusyoung commented 4 years ago

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

ben-xD commented 4 years ago

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

AhmedThahir66 commented 4 years ago

Any updates on this?

AhmedThahir66 commented 4 years ago

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

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

phisanti commented 4 years ago

Any update on the addition of bibliography support?

chonuchan commented 4 years ago

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

phisanti commented 4 years ago

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?

leowill01 commented 4 years ago

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.

maxfrischknecht commented 3 years ago

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.

ghost commented 3 years ago

any updates on this one ?

zottelsheep commented 3 years ago

Adding to @leowill01 suggestion, maybe there could be a block similar to [toc] that all the references get automatically added to.

This way you could have a .bib file with all your metatdata and when you actually cite something, the metadata gets read from the .bibfile and added to the references-block.

For syntax maybe something along the line of [ref] or [bib].

As for specifying the path of the .bib file, maybe there could be a global option in the preferences that can be overwritten via the YAML-Header. Maybe one could also specify the citation style in the preferences with simple syntax using variables: "${id} ${title} ${author} ..." Basically the variables that are used within the bibtex format.

I'd really like to see this happen. It would make writing academic papers so much easier and Typora even more awesome!

egordm commented 2 years ago

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]`.

Hi. I have noticed that if you change line:

text: /^(\s|\S)+?[^\n\t\u200B\uE010-\uE020\uE006\uE023\uE031\\<!\[._*`&{\$\:~\^\="'\-]*/,

to

text: /^(\s|\S)+?[^\n\t\u200B\uE010-\uE020\uE006\uE023\uE031\\<!\[._*`&{\$\:~\^\="'\-@]*/,

Then in citations without brackets also work. It seems to be responsible for splitting the text into parseable blocks.

w-zhiwei commented 2 years ago

any updates?

phense commented 2 years ago

Would love to see proper citations and citation-autocompletion, as mentioned above.

sarahtanja commented 1 year ago

Still in need of this feature ^

Drew015 commented 1 year ago

I hope it will support this feature in future

clemsos commented 1 year ago

please, still needed

eriksdev1 commented 1 year ago

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)

By any chance do you or anyone knows if someone already made a cite as you write script in windows for Typora ? Something like a zotero picker that could work in Typora ? Thanks in advance.

KuruGit commented 1 year ago

I am also very interested in a bibtex integration. As @eriksdev1 already mentioned there is already a usable API Endpoint that could be integrated into Typora.

ZJsheep commented 11 months ago

Interested in it. At least provide some support for render bibtex items?