tab-copy icon indicating copy to clipboard operation
tab-copy copied to clipboard

custom plain-text format instead of html format

Open iamqiz opened this issue 1 year ago • 6 comments

I want to copy other markdown format like this:

[title][n][[url]]([url])
Example 1
[https://www.example.com/](https://www.example.com/)

Example 2
[https://example.com/search?q=kittens](https://example.com/search?q=kittens)

Tab Copy
[https://tabcopy.com/](https://tabcopy.com/)

but when I use "custom format" to realize it , tabcopy use 'html format' to copy it beside 'text format', so that when I paste it to a note app, the note app recognize the html format ,but it will misunderstand the markdown format in that html format, so i hope tabcopy can add a option to allow user to decide whether the data will be copied in 'html format' or 'only plain-text format' thanks !

iamqiz avatar Dec 07 '24 22:12 iamqiz

by the way, would you please add 'Plaintext fallback' for custom format? like https://github.com/hansifer/tab-copy/issues/7 thanks!

iamqiz avatar Dec 07 '24 22:12 iamqiz

I think there's definitely use cases for control over variants in custom formats. Not quite sure how to surface that quite yet though.

Custom formats are currently copied in both plain text and HTML variants to accommodate Link tokens. If you're not using a Link token in your custom format definition, either variant should produce a similar result when pasting. See: format variants.

Can you provide some more detail about what you're expecting vs actual result? What does "misunderstand the markdown format" translate to in practice? Please include specifics like which note app you're pasting into and how. When I try your custom format and paste into Obsidian, for example, the result is as expected... pairs of title & clickable url.

hansifer avatar Dec 07 '24 23:12 hansifer

my note app is siyuan , it has a bug that it will escape some char in html format( it does not escape char in plain-text format) ,for example: [aa](https://example.com/?arg1=hello_world) will be recognized to [aa](https://example.com/?arg1\=hello\_world, it escape _ to \_ and = to \=, so that the link will be broken.

in my case,I hope html format is [title][n][[url]]([url]) (a title and a markdown link) and its plain-text format is [title][n][url], so that I can paste a title and clickable link in note app, meanwhile paste a title and a url in other place such as code editor

iamqiz avatar Dec 08 '24 03:12 iamqiz

I see. Thanks for the additional detail.

I think it makes sense to extend custom format authoring to allow advanced users to enable/disable or separately define an HTML format. The trickier parts are maintaining UI simplicity for the majority of users and dealing with tokens that themselves have both a plain text and HTML representation. Doable but requires some thought.

As a workaround, does siyuan allow you to paste as plain text? Perhaps with cmd+shift+v (or ctrl+shift+v)?

hansifer avatar Dec 08 '24 17:12 hansifer

It seems that custom format does not support html syntax, I set it to <a href="[url]">[title]</a>,and copy google url, its plain text is <a href="https://www.google.com/">Google</a> and its html format is as follow( view it with Free Clipboard Viewer):

<html>
<body>
<!--StartFragment-->&lt;a href=&#34;https://www.google.com/&#34;&gt;Google&lt;/a&gt;<!--EndFragment-->
</body>
</html>

Shouldn't it be like this? (like 'link' format)

<html>
<body>
<!--StartFragment--><a href="https://www.google.com/">Google</a><!--EndFragment-->
</body>
</html>

As a workaround, does siyuan allow you to paste as plain text? Perhaps with cmd+shift+v (or ctrl+shift+v)? siyuan will paste as plain text but will not recognize it into link

thanks!

iamqiz avatar Dec 10 '24 01:12 iamqiz

It seems that custom format does not support html syntax

That's correct. Since there is only one template for both plain text and HTML currently, we cannot assume the template is being authored as HTML. An optional "rich text" format as discussed above could support direct HTML authoring or perhaps use a rich text editor to generate it.

hansifer avatar Dec 10 '24 01:12 hansifer