Markdown export: Colors and tags in output

This discussion was created from comments split from: Available for beta testing: Markdown export of notes.
  • This is not a whinge.
    But can I just confirm that it is presently impossible to export the colours of highlights to markdown from the new PDF editor?
    Equally, that the the tags on annotations don't for the moment export?

    The obvious workaround, if you're exporting to Obsidian, is to add tags manually for the categories that we might use colours and tags for.

    eg #checkthis #srsly-huh #crucial or #disputed

    and I am happy to do this, which is only a few more keystrokes. But I just want to be sure that this is the only way to do it for the moment, and that any plans to format the Markdown from within Zotero are at the moment still just plans
  • But can I just confirm that it is presently impossible to export the colours of highlights to markdown from the new PDF editor?
    Correct. But if that's something you want, you'd have to say more about how you see that working, given that Markdown is plain text (assuming you don't want actual HTML tags). The fixed annotation colors currently in the Zotero PDF reader could have hard-coded, localized names, but annotations coming from external PDF readers aren't fixed, and the built-in reader might support user-defined colors in the future.

    Do you want to be able to add manual labels to colors? Do you want to simply associate a color with a tag, such that choosing a color was equal to adding a specific tag? Do you want those color labels to be document-specific (such that you had to assign them again in every new document) or global across all documents (such that changing a color label in one place would affect the meaning of the color in all previously annotated documents)? In a group library, should color labels be shared with and editable by all group members?

    These are tricky questions, which is why we opted to keep colors and tags separate and keep colors unlabeled in the initial version.
    Equally, that the the tags on annotations don't for the moment export?
    Correct. But that will certainly be possible in a future version.
  • Thank you for clarifying the difficulties and uncertainties here. Because I use Obsidian, with its very flexible system of styling markdown elements through css, it's easy to overlook the range of complication involved with other editors.

    Speaking for myself, I would strongly prefer the colour-label associations to be document specific, for two related reasons.

    1) the range of characteristics salient enough to be tagged is very wide and varies between documents: a colour/tag might represent a theme in a long document; it might represent an action to be taken; it might represent a reader's reaction; in a playscript it could be something as simple as a character's speech or PoV. Any particular document is going to be tagged in only a subset of these possible ways, probably no more than five. But we don't know which five in advance

    2) asking people to choose a group of colours/tags is unrealistic at the start of a project but changing things retrospectively at the end of a project or the start of a new one is going to be very confusing.

    I don't think those points will prove very controversial — though it would obviously be good to have a set of sensible defaults.

    As to the question of hard-coding colours: I think it would be a reasonably compromise for Zotero to offer a range of seven colour names/swatches (isn't that what it does now?) and for users to be able to map the colours used in other programs onto these. The reason being that most people are unlikely to want to use, or to be able to distinguish, a large number of highlight shades.

    Giving them names would allow customisation both on the importing and the exporting sides of Zotero, so that people could see the exact shades they preferred in external PDF readers or the reader apps for exported notes.

    For the moment, though, the most useful thing would be the ability to export the tags on individual annotations with or without the coloured highlights.
  • Would it be possible to do away with the tag feature on notes and instead replace it with inline tagging in comments with "#tag"? This is how Obsidian and Dendron tag items, and in this way the exported note would already include the tag. Essentially what I am asking about is auto-completion/recommendation on writing #tag within the comments of a note. Of course this only food for thought, I am sure some people do like current tagging system.
  • This is a great feature! I also use Obsidian and just wanted to add my vote that it'd be useful to have colors hard-coded into the notes (ie Green - "blah blah blah"). I only use 3 colors, so it's easy enough for me to remember without matching tags to colors, but I can see where that might be useful for others.

    Additionally, I'd love it if I could have my notes appear in a block quote and my highlights appear normally. It helped visually to see where my ideas were. That was a nice feature in Zotfile.

    Finally, I use Acrobat for annotating and highlighting. For some reason, using this beta feature, when I click on the "Show on Page" link, it just opens the document to the very beginning as opposed to taking to where the highlight is.

  • edited March 11, 2022
    You know what? I just saw this...https://www.zotero.org/support/note_templates
    Nice work! I've got the block quotes working as intended, the only thing that is a little weird is that it adds a blank block quote even if there is not a comment (that's only when I'm viewing the note in Zotero though, when I copy all and paste it into a new note in Obsidian, there are no empty block quotes).
  • edited March 11, 2022
    Here's what's working for me (regarding blockquotes), as a reference for anyone else who comes across this... Sorry, unsure how to format code in this forum so it's not showing up totally right...

    <p>{{highlight quotes='true'}} {{citation}}</p>{{if comment}}<blockquote>{{comment}}</blockquote>
  • I also use Obsidian and just wanted to add my vote that it'd be useful to have colors hard-coded into the notes (ie Green - "blah blah blah").
    Note that you can do this with a note template as well. See the conditional color examples in the note template documentation.
  • edited April 21, 2022
    In note templates, I am trying to export highlight colors to markdown so they are visible in Obsidian. It is not working. What am I doing wrong?
    {{if color == '#ff6666'}}
    <mark style="background: #ff6666; "><p>{{highlight}} {{citation}}</p> {{if comment}}<blockquote>{{comment}}</blockquote>{{endif}}</mark>
    {{elseif color == '#2ea8e5'}}
    <mark style="background: #2ea8e5; "><p>{{highlight}} {{citation}}</p> {{if comment}}<blockquote>{{comment}}</blockquote>{{endif}}</mark>
    {{elseif color == '#5fb236'}}
    <mark style="background: #5fb236; "><p>{{highlight}} {{citation}}</p> {{if comment}}<blockquote>{{comment}}</blockquote>{{endif}}</mark>
    {{elseif color == '#a28ae5'}}
    <mark style="background: #a28ae5; "><p>{{highlight}} {{citation}}</p> {{if comment}}<blockquote>{{comment}}</blockquote>{{endif}}</mark>
    {{else}}
    <mark style="background: #ffd400; "><p>{{highlight}} {{citation}}</p> {{if comment}}<blockquote>{{comment}}</blockquote>{{endif}}</mark>
    {{endif}}
  • edited April 21, 2022
    Ok, so I changed the conditions to export notes in bold and bold&italics depending on highlight color which allows me to distinguish three separate kinds of notes on export. But if I can add <i></i> and <b></b> why doesn't the other code register, if the notes are in markdown?
  • @erazlogo Markup that isn't supported in Zotero note editor will be stripped.
  • edited May 11, 2022
    I've just stumbled onto this discussion and have done some experimentation with these variables. To include the tags in the annotations I used:
    <p>{{highlight quotes='true'}} {{citation}}</p>{{if comment}}<blockquote>{{comment}}</blockquote>{{endif}} {{if tags}} <blockquote><b>Tags:</b> #{{tags join=' #'}}</blockquote>{{endif}}

    While it probably can't be used by any external application for direct import at least there is now an annotation with a note and accompanying tags.

    11 May 2022: I tried setting extensions.zotero.annotations.noteTemplates.highlight to this with great effect for importing into Obsidian:
    <p>{{highlight quotes='true'}} {{citation}}</p>{{if comment}}<blockquote>{{comment}}</blockquote>{{endif}} {{if tags}} <blockquote><b>Tags:</b> [[{{tags join=']] [['}}]]</blockquote>{{endif}}

    It will automatically include the tags associated with the Notes added to a PDF.

    I will add I am very much a novice in this realm. I'm still trying to find my research feet.

    Hope this helps.
    God Bless
  • edited May 20, 2022
    Thanks a lot for all the good work!

    I am trying to get info about my highlight colouration into Obsidian. I modified the extensions.zotero.annotations.noteTemplates.highlight to get a coloured square-like structure into my annotations (<blockquote><span style="background-color:{{color}}">|–|</span> {{highlight quotes='true'}} {{citation}} {{comment}}</blockquote>). No problem to make it work a this point. I have lovely squares of colour as wanted. But then, when I try to export it to Markdown (and into Obsidian), the span command is forgotten, and I only get a sad colourless square. Did I make something wrong? Did I forget something important?

    Thanks in advance!
  • edited May 20, 2022
    @Hydraginium: A span wouldn't be represented in Markdown export. What were you expecting? The only option would be to include raw HTML, which likely isn't what most people want when exporting to Markdown.

    You can export in HTML mode if you want to preserve the HTML.
  • @dstillman

    Thanks for your answer! Well, I do not know what I was expecting, but from an amateur point of view, what I thought about made sense to me.

    I tried incorporating HTML, but then it is the Extract Annotations function which deletes the code, even before exporting to Markdown.

    I am really sorry to bother you with this issue of mine. I thought getting the highlighting colours into my Obsidian notes would be easier...
  • @hydraginium you might want to ask this question on the Obsidian Discord - there are ways to post-process some kind of plain language markup to a color callout--I think that is what you want. https://discord.com/channels/686053708261228577/722584061087842365

    I do agree that there should be a way to export highlight colors--it seems odd that they get lost. Zotfile export highlight colors.
  • I tried incorporating HTML, but then it is the Extract Annotations function which deletes the code, even before exporting to Markdown.
    This is some sort of misunderstanding. I'm saying you can just export the note in HTML mode, which will preserve the spans you've added to the note template (i.e., the "lovely squares of colour"). Markdown is a plain-text format, so there's no way for it to include color other than embedding raw HTML, which defeats the purpose of being a plain-text format. If you save a note created with your note template in HTML mode, you'll get an HTML file with the color swatches.
    I do agree that there should be a way to export highlight colors--it seems odd that they get lost. Zotfile export highlight colors.
    Well, ZotFile didn't "export" anything. It extracted annotations to Zotero notes. Zotero, too, embeds the color information in annotations you add to notes, but in a more flexible way than ZotFile — which is why you can toggle annotations colors on and off. The only issue is that Zotero's HTML note export doesn't yet include any customization options, and it doesn't include the color by default, so it's not currently possible to include the color in the HTML export other than by using a note template to put the color in a span like @Hydraginium is doing. We'll be adding color options for HTML note export in an upcoming version.
  • Thanks @erazlogo, I'll take a look at the Discord and ask questions if necessary.

    @dstillman I understand better how it is working now. Thanks a lot for your answer!
Sign In or Register to comment.