'Create Bibliography', markdown-formatted

Is it possible to format a bibliography using markdown syntax? That is, to select a number of items in a Zotero library, right-click to choose Create Bibliography From Item, but then instead of having the formatted text copied to clipboard, have the markdown that would lead to those same formattings.
  • edited November 2, 2020
    No, but you can copy as HTML code, which is valid Markdown, using Quick Copy. (Or you can save as HTML using "Create Bibliography from Items" and copy the HTML from the file, but that's more work.)

    Markdown itself can't properly represent all the formatting that citation styles require, so this wouldn't make sense. But you can always paste HTML into a Markdown document.
  • ah yes, that makes indeed more sense. Thank you!
  • Markdown users may also be interested in this add-on: https://github.com/argenos/zotero-mdnotes
  • It should be noted that HTML itself also can't properly represent all the formatting that citation styles require. Both HTML and Markdown would need CSS to do the right thing. So, Markdown makes just as much sense as HTML. It would look something like.

    Instead of

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">;
    <html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Bibliography</title>
    </head>
    <body>
    <div class="csl-bib-body" style="line-height: 1.35; margin-left: 2em; text-indent:-2em;">
    <div class="csl-entry">Lastname, Firstname. <i>This is the Title</i>. North Charleston, SC: Publisher's Name, 2017.</div>
    <span class="there is a mysterious secret span here that I deleted"></span>
    <div class="csl-entry">Glen. “GTD Cheatsheet: The Workflow.” LifeDev, February 1, 2007. <a href="https://lifedev.net/2007/02/01/gtd-cheatsheet-the-workflow/">https://lifedev.net/2007/02/01/gtd-cheatsheet-the-workflow/</a>.</div>;
    <span class="there is a another mysterious secret span here that I deleted"></span>
    </div></body>
    </html>


    . . . You'd have . . .


    <div class="csl-bib-body" style="line-height: 1.35; margin-left: 2em; text-indent:-2em;">
    <div class="csl-entry">

    Lastname, Firstname. _This is the Title_. North Charleston, SC: Publisher's Name, 2017.

    </div>
    <div class="csl-entry">

    Glen. “GTD Cheatsheet: The Workflow.” LifeDev, February 1, 2007. [https://lifedev.net/2007/02/01/gtd-cheatsheet-the-workflow/](https://lifedev.net/2007/02/01/gtd-cheatsheet-the-workflow/).

    </div>
    </div>

  • @t0dd: I mean, those aren't comparable — you're including document, head, and body tags in one and not the other, and you're removing the COinS span that lets the data be saved back to Zotero. When you save a file via Create Bibliography from Items, it creates a full HTML file, but for just dropping in a Markdown document you would copy HTML via Quick Copy, where you get just the csl-bib-body div.

    So the only actual differences are the italics and the link, which are pretty minimal, and if the whole thing has to be wrapped in HTML tags for styling anyway, who cares? You just ignore that block. This isn't body text that's meant to be human readable or writable.
  • @dstillman I understand what you are saying and I am not heartbroken over it, but the differences are the italics, the link, *and* all that headers cruft which is unneccessary in a markdown file, whether a full file or a snippet. Put another way, the HTML is markdown + converted italics and links + a bunch of added headers and wrapper html.

    The div tags are only there to apply CSS. That is how you do it with markdown and in HTML. So ... that is their only similarly really.

    The HTML is HTML + CSS.
    The markdown is markdown + CSS

    To use it as markdown standalone or as a snippet, I would have to do the link and italics conversion and strip out all the excess. Just extra work. Yes, you could leave the links and italics as is, but ... that's just sloppy, IMHO.

    My hand created stuff looks even more stripped down (and I move the CSS to a stylesheet), but that is beyond the discussion:

    <div class="csl-bib-body" style="line-height: 1.35; margin-left: 2em; text-indent:-2em;">

    Lastname, Firstname. _This is the Title_. North Charleston, SC: Publisher's Name, 2017.

    Glen. “GTD Cheatsheet: The Workflow.” LifeDev, February 1, 2007. [https://lifedev.net/2007/02/01/gtd-cheatsheet-the-workflow/](https://lifedev.net/2007/02/01/gtd-cheatsheet-the-workflow/).

    </div>


    But I can see how someone might want two layers of CSS there. I digress.

    The span. I had no idea why it was there. So I suppose that remains. How does that work with an RTF document?

    My meager vote is to include markdown notes as an option, but my vote is only one small vote and I just wanted it filed in the comments. Thanks for listening. :)
  • edited February 7, 2021
    the differences are the italics, the link, *and* all that headers cruft which is unneccessary in a markdown file, whether a full file or a snippet
    No, you're still misunderstanding this. Again, nothing outside of the csl-bib-body div appears if you use Quick Copy, which is what you would be doing if copying into a Markdown file. So the only relevant comparison here is the two csl-bib-body divs. And the COinS span serves a functional purpose, so you can't just arbitrarily remove that in one if comparing the two. So, again, the only differences are the italics and the link.

    If you need HTML divs, inline CSS, and COinS spans in both, then it just makes no sense to worry about the italics and link, which are barely noticeable in the context of the rest. It's just a chunk of HTML that you paste in to get a bibliography, the same as any other special-purpose block of HTML you might paste into a Markdown file. Just ignore it.
    My hand created stuff looks even more stripped down (and I move the CSS to a stylesheet), but that is beyond the discussion
    The inner divs aren't optional for many citation styles, so this isn't a relevant example.
    The span. I had no idea why it was there. So I suppose that remains. How does that work with an RTF document?
    The COinS lets Zotero save data from webpages. (The 'S' in COinS stands for 'spans'.) It's not relevant for RTF.
  • @dstillman OK. I guess I am not understanding the purpose of having the option of downloading an HTML or RTF file if everyone is only supposed to use Quick Copy. I can see the advantage of smashing HTML into a markdown by using Quick Copy because it strips out some of the cruft. But that is only because I don't really have any other option. If I could download a .md file, that would be nice. As for the spans, I don't see it as being relevant to markdown either, but I may be wrong.

    Look. You don't have to respond. I see your point that HTML can be used in markdown and it just does the right thing. And you can't go the other direction. I just like to keep my documents as clean as possible. There are converters I can use to take an HTML file and make it markdown. And that is probably what I will end up doing.

    Thanks again for clarifying things. Cheers.
  • edited February 7, 2021
    I guess I am not understanding the purpose of having the option of downloading an HTML or RTF file if everyone is only supposed to use Quick Copy.
    It's not that you're only supposed to use Quick Copy. But if you're trying to add something to a Markdown document, the whole point of which is to be human-readable, presumably there's already other human-readable content in the document, so pasting something in via Quick Copy makes sense. With HTML output in Create Bibliography, you can use the output file as is if you really want to. But there'd be no reason to output to Markdown if you were just using the output as is.

    The main other benefit to Create Bibliography is that you can configure the style settings on the fly, and if you want that for your Markdown document, you can take the extra two seconds to strip the headers. But the csl-bib-body, for the reasons I've explained, would be almost entirely the same even in a Markdown version, so it wouldn't make sense to create an option called "Markdown" for Create Bibliography whose main difference was not including the HTML header. This use case would be better addressed just by providing an option in the dialog to copy to the clipboard as an HTML snippet instead of formatted text, as is an option with Quick Copy.

    (RTF isn't really relevant here. That needs to be a file to be openable in word processors.)
    As for the spans, I don't see it as being relevant to markdown either, but I may be wrong.
    The standard output of Markdown is HTML, so if you want Zotero to be able to import data back from the webpage, you would want to keep the span.
  • Not just the headers. You strip them out, the body and HTML tags, add spacing, convert italics and links. And I think the span (my markdown documents are documents, not webpages). And have it downloadable as a stand-alone document and as quick copy. I'd like markdown. Not HTML. It's as simple as that. I can do the work to clean up the cruft, but man, it can get annoying fast, especially if you are iterating.

    So, I disagree with your logic. We shall agree to disagree. :) My vote is noted. Well, I think it is noted. Maybe I should just open a github ticket instead.

    Cheers.
  • nah, this is were discussion happens. Zotero uses github tickets to track things devs are planning to implement, so if you open one for md it'd just get closed immediately.

    FWIW, I know there are use cases for just copy&paste, but my sense is that most people working/writing in markdown (of which there are many) just create the bibliographies via pandoc/pandoc-citeproc (for which there a number of elegant workflows from Zotero) and the main use case for copy&paste are people using md to build jekyll or hugo websites, for which the html option actually provides a better solution, so yours is a pretty niche request.

    Could probably be done by an add-on which might be as simple as re-converting the html output to md automatically.
  • Not niche in the least. Heh. But whatever. You guys see no value in it, so moving on.
Sign In or Register to comment.