Skip to content

[FEATURE] Ways to improve compatibility with other markdown editors #3225

@netlimpopo

Description

@netlimpopo

Compatibility between QOwnNotes and other Markdowneditors

Motivation

Markdown editors differ when it comes syntax notations for markdown links. Advanced features like updating links upon file/folder renaming depend on the specific markdown syntax for a particular programme. Also simple things like referencing headings show different syntaxes and therefore will sometimes not be updated on renaming due to a deviating notation. Overall, this causes links to break.

An idea is to provide a way to import markdown files, adapt the "standard" markdown links and fix deviating syntaxes, so one can easily work in multiple Markdowneditors at the same time or swap between editors easily. I am thinking of writing a script for that purpose, but maybe it is more useful to change the programme code in order to deal with differnt syntaxes.

Note, I understand that not every exotic syntax needs to be implemented that is actually allowed by e.g. commonmark, therefore translating foreign syntax into readable one seems the easier choice.

There are two sides of the coin:

A) Importing files from some random editorintoQownNotes: Random Editor ↦ QOwnNotes
B) Exporting files from QOwnNotes to some random editor : Random Editor ↤ QOwnNotes

Most significant incompatibility types

There are 5 major incompatibility issues:

  1. [Link][URLENCODEDlinkpath] Different handling of URL encoding of characters in links + different handling of special characters within them.
    ↦ Some programmes make exceptions for "German Umlaute" oder accents or greek Symbols etc. and show them unencoded in the link path for readability purposes.
    ↤ QOwnNotes strictly URL encodes links - other programmes leave Ö, Ü, Ä, Ø, etc. as is. Other programmes might not know what to do with QOowNotes links:
    [Ü 3 - H 2 in Ü 3](F2/F3/%C3%9C%203.md#H%202%20in%20%C3%9C%203)

  2. [Link][URLENCODEDLinks#with-heading or with%20Heading?] Different heading syntax: #with-heading or with%20Heading? Lowercase letters and -delimiter vs. URL encoding (e.g.%20) and leaving capital letters.
    Additionally should special characters be URLencoded? (see. 1)

  3. [Link][./with%20dot%20and%20slash]: relative links with leading ./ producded by VS Codium to emphasise the relative nature of links compared to absolute links: [Link][/folder/with%20and%20slash]. Those links should ideally be supported by QN in the future as they are quite common amonst editors.

  4. [Link][<Angle Bracket links>] (supported by commonmark): Renaming or moving files/folders in VSCodium creates these. QN does not support them fully (especially when moving files and updating links).

  5. [Link][<Angle%20Bracket%20links%20with%20spaces%20replaced%20by%20>]: Subcase of 4. just with URL encoding or not.

Current Solutions

  • Search through alle files and replace problematic syntax by regular expressions.
    • Special care needs to be taken in order to not corrupt files (proper RegEx)!!
  • I use a Notepad++ macros for convenience but any language will do
  • Obsidian offers an import function for foreign markdown files to tranlate them into Obsidian markdown
  • Obsidian offers an option to constantly adapt links to support all Obsidian features

Possible Script implementation (ordered by importance)

Import to QN

  • Change [](<name.md>) to [](name.md) and [](<name with space.md>) to [](name%20with %20space.md)
  • Remove [text](./link.md)[](link.md) (QN does not update these links on file move. This should probably be added)
  • Url-encode special characters [](Ö.md) to [](%C3%9C.md>)

Export from QN

  • Url-decode special characters [](%C3%9C.md>) to [](Ö.md) especially in links with headings.

Open Questions and to-dos

  • Scripting in QN is basically Javascript inside QML files, is there already a function for urlencoding?
    • escape() will not encode: @*/
    • encodeURI() will not encode: ~!@#$&*()=:/,;?+'
    • encodeURIComponent() will not encode: ~!*()'
    • QT specific URLencode?
  • What types of regex does QN support, especially in scripting? positive lookahead and stuff? Find Docu.
  • Should QN leave "Umlaute" like in the notelist-panel and just internally URL encode them? (for readability and saving space)

Possible Problems and Dangers

Folderwide replacement might lead to false positives. Work thoroughly and with great care! Write a note to back up the files first.

Checked Programmes that are similar to QOwnNotes

Overview over supported features (subject to change with new versions)

u.o.f.m./r. = update on file move/rename

Feature QN Markor VSCodium Obsidian Joplin
Clickable link with special characters for better readability [Text](ÖÜÄà.md)
Link u.o.f.m./r. for [Text](ÖÜÄà.md) x x ✓ (converts to [Text](<ÖÜÄà.md>) ✓ (only with Plugin)
Link u.o.f.m./r. for URL encoded link [Text](%D6%DC%C4%E0.md) x semi: depends on characters semi: (Plugin 1) URLDEcodes links 2) rewrites links) semi: works with file ids
Link to heading "With Überschrift" strictly URLencoded: "With%20%DCberschrift" #with-überschrift (lowercase) #with-überschrift (lowercase) semi URLencoded: "With%20Überschrift" ?
Link u.o.f.m./r. for URL encoded heading link [Text](file.md#With%20%DCberschrift) x semi(depends on special characters) ✓ (Plugin rewrites links first)
Analog u.o.f.m./r. + with original special characters [Text](file.md#with-überschrift) x ✓ (Plugin rewrites links first)
Angle Bracket links [Link](<Link with Spaces.md>) clickable x ?
Angle Bracket links u.o.f.m./r. [Link](<Link with Spaces.md>) x x ?
Angle Bracket links URLenc. clickable [Link](<Link%20with%20Spacesencoded.md>) ?
Angle Bracket links u.o.f.m./r. [Link](<Link%20with%20Spacesencoded.md>) x ✓ (Plugin) ?
Relative Links with ./ clickable
Relative Links with ./ u.o.f.m./r. x (hopefully suppported in the future x ✓ (plugin)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions