Markdown render for items with md tag

22 views
Skip to first unread message

Gergely K.

unread,
Sep 17, 2020, 7:40:50 AM9/17/20
to CopyQ
 Hi all!

I tried to modify the markdown display script to render markdown only for items with md tag, but failed. My attempt was:
[Command]
Command="
    copyq:
    popup(\"tags: \", plugins.itemtags.tags()) // cannot see the tags, but there **are** tagged items
    if (plugins.itemtags.hasTag('md')) {
      text = data(mimeText)
      result = execute('markdown-it', null, text)
    
      if (result && result.exit_code == 0) {
        setData(mimeHtml, result.stdout)
      }
    }"
Display=true
Icon=\xf15b
Name=markdown

Can you help me to spot what was my mistake?
thanks
Gergo

Lukáš Holeček

unread,
Sep 18, 2020, 11:55:29 AM9/18/20
to Gergely K., CopyQ
Hi,

Functions `plugins.itemtags.tags()` and `plugins.itemtags.hasTag()` work only with Menu type commands.

In display commands you have to get the tags with:

    copyq:
    var tagsData = data(plugins.itemtags.mimeTags)
    var tags = str(tagsData).split(',')
    if (tags.indexOf('md') != -1) ...

Lukas

--
You received this message because you are subscribed to the Google Groups "CopyQ" group.
To unsubscribe from this group and stop receiving emails from it, send an email to copyq+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/copyq/1faa8148-8ceb-4c8e-bb10-2d03fb1be4ebn%40googlegroups.com.

Gergely K.

unread,
Sep 21, 2020, 9:27:26 AM9/21/20
to Lukáš Holeček, CopyQ
Thanks a lot, that worked.
--
Mobile:(+36 20)356 9656
"Olyan lángész vagyok, hogy poroltóval kellene járnom!"
Reply all
Reply to author
Forward
0 new messages