Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Automatically turn hashtags to tags #206

Open
pabloscloud opened this issue Mar 23, 2024 · 3 comments
Open

[Feature Request] Automatically turn hashtags to tags #206

pabloscloud opened this issue Mar 23, 2024 · 3 comments
Labels
feature request New feature or request

Comments

@pabloscloud
Copy link

pabloscloud commented Mar 23, 2024

Is your feature request related to a problem? Please describe.
I tried importing markdown files from logseq, but need to convert all tags I created inside of logseq to actual tags in cryptee.

Logseq also uses a special version where they use [example] instead of #example so that names with spaces can be tags. I'd love to see this in cryptee as well but that's not a biggie.

@johnozbay
Copy link
Member

Hey @pabloscloud! 👋🏻

Thanks for filing this 🙏🏻

— Apologies for the delayed responses here, we have been extremely busy since the whole EU / US vs Apple saga began and I had to testify in March.

I wrote a little bit about Markdown in #204 — specifically about how [xyz] style doc-to-doc links / tags annotation etc is non-standard and not a part of the official markdown spec.

And since Markdown doesn't support tons and tons of features Cryptee has (tags, tables, font sizes you name it), we don't use Markdown as a storage format, because it wouldn't be interoperable or safe to do so.

We can add a custom tag format by hand and extend on our own shortcuts while typing in stuff though. (importantly however, this wouldn't work while importing/converting markdown files to cryptee docs — it would only work while typing in realtime. Making sure our importer works would require us to build upon the markdown spec, since our importer is following the markdown spec for interoperability reasons.

(and occasionally we cheat to allow github flavored markdown (GFM) specs, i.e. in cases of tables)

<script lazysrc="../js/lib/turndown/turndown-plugin-gfm.js" loadafter="windowload"></script>

Let me know what you think, and we can consider adding in another shortcut to tags if that would help your use case — even though these tags won't be visible on export to markdown.

Hoping this makes sense.

All the best,

J

@johnozbay johnozbay added the feature request New feature or request label May 16, 2024
@pabloscloud
Copy link
Author

I get that you don't use markdown to store notes, but when importing a markdown file (either by uploading or copy pasting) cryptee could identify the hashtags in the text and convert words to tags, right? I don't care too much about these bracket tags (which just added the functionality of having multiple words as one tag).

Hope that makes sense! I appreciate all your work towards apple drama and the public chats with Henry from Techlore on yt ;)

@johnozbay
Copy link
Member

Thanks for getting back and your kind words!

It's a little trickier, but we maaaay be able to do this.
The difficulty is, think of our importer and our realtime-detector as two separate engines.
The thing that bulk-parses text is not the same as the thing that listens for you type keys and trigger shortcuts

i.e. when you press # it triggers the app to start listening like : ok the keys that are about to get pressed now are the tag, until user presses spacebar or return.

But when you bulk import, you don't go through the text character by character, as that would be insanely inefficient.

And if we do simple regex detection for things like # symbols etc, it opens the doors to two problems.

  1. it quickly becomes a lot of work to go through character by character, for each edge cases.
    i.e.
    # ->space -> text => H1 TEXT,
    ## -> space-> text => H2 TEXT etc
    So you need to go through all possible scenarios many times for each combination the editor. Any tiny change that deviates from markdown standard = means you'll have to maintain a parallel markdown standard spec for life now.

  2. it makes it possible for people to try and attempt XSS attacks by using # symbols. We utilize DOMPurify when importing HTML / Text / Markdown etc into Cryptee, so that you can't import a malicious HTML/TXT/MD file into Cryptee that could attempt to steal your keys. And the first rule of XSS prevention is : don't sanitize first, then modify / make changes.
    (i.e. in this case, change hashtags to something else after sanitization & markdown import)

So I'm going to look into this and see if we can detect # tags before we import markdown / sanitize. But, this means inserting our custom tag-code into the markdown, then recovering it from the markdown parser. (and hope that it doesn't break it) But no promises.

TLDR; Point being :
Markdown spec doesn't support tags.
If you want tags and data portability you should use HTML / ECD / UECD files.

All implementations of markdown you see in the wild that support tags are custom, random, non-compliant, not-interoperable implementations made by others. Even here on Github, in this text editor. If you use # it makes it possible to link issues to one another. YET, this feature is not a part of github flavored markdown spec.

Hoping this makes sense!
Will keep this thread posted once we have more info ✌🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants