-
Notifications
You must be signed in to change notification settings - Fork 340
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
Fix conformance to Zim (and enable Insert Audio button): wrong attachment directories, linked file not found, missing image link's tags, minsdk 16-18 #2147
base: master
Are you sure you want to change the base?
Conversation
Hello @mehw the CI shows some build errors with these PR changes. Can you please check/fix that? |
@gsantner I'm on it. |
The format {{}} is for images, other types should use [[]] instead. References: - https://github.com/zim-desktop-wiki/zim-desktop-wiki/blob/c88cf3cb53896bf272e87704826b77e82eddb3ef/data/manual/Help/Wiki_Syntax.txt
While editing a wiki file, Zim adds links to a target residing inside the Notebook (where notebook.zim file is found) resolving the path as relative to the wiki file's attachment directory (same parent/name of the wiki file, but without the extension). If a link's target is not a child of the Notebook, Zim adds the link as an absolute path. Zim always prefixes relative paths, adding './' if a link's target is a child of a wiki file's attachment directory. /home/user/Notebook # Notebook directory | | | `- notebook.zim # marks the root of the Notebook | | | `- wiki-example # wiki file's attachment directory | | | | | `- video.mkv # wiki-example.txt file attachment | | | `- wiki-example.txt # wiki file written in wiki markup | `- README # file outside the Notebook's root In wiki-example.txt, [[./video.mkv]] would be a link to an attachment residing in the 'wiki-example' directory. Linking notebook.zim would add [[../notebook.zim]], and [[/home/user/README]] would be a link to a file outside the Notebook.
Zim uses the path of the .txt wiki file for attachments, but without the extension, i.e. wiki-text.txt would be connected to wiki-text as attachment directory.
Zim local paths are relative to the current wiki file's attachment directory. Properly resolve an attachment path to edit the image.
Zim inserts file links relative to a wiki page's attachment directory, if the target is a child of the Notebook. Adapt the conversion of Zim wiki pages to markdown, translating Zim file links accordingly.
Assume the current directory as top link if root cannot be determined.
Zim may insert attributes, as html tags, in an image link: id, width, height, type, href. {{./image.png?href=.%2Fvideo.mkv&id=anchor-name&width=50}} In markdown [![name](image)](link) is close to the above, but without the possibility to insert extra tags.
Add logic to insert an audio recording/link.
Adding myself to CONTRIBUTORS.md
@gsantner I changed a test to reflect a new behavior, this fixes the CI: assume the current directory as top link if root cannot be determined. I thought this as a fallback, but also if the user wants to organize a notebook as a relative structure, without a specific root directory. When markor/app/src/main/java/net/gsantner/markor/format/wikitext/WikitextLinkResolver.java Lines 94 to 95 in 856175f
|
Due other PR's edited the same files/things, there are merge conflicts now. Can you please fix it? |
@gsantner I will look into it in these days. Forgive me for leaving you hanging. |
no problem |
Hello,
This series of patches is to conform the wikitext format to Zim:
{{}}
is for images, other types should use[[]]
.id
,width
,height
,href
; images can link other files.As an extra, the Insert Audio button is enabled.
More descriptions about Zim conformance are in the commits and in the code as comments.
Zim attachment directories
In
wiki-example.txt
,[[./video.mkv]]
would be a link to a file residing in thewiki-example
directory (relative path). Linkingnotebook.zim
would add[[../notebook.zim]]
, and[[/home/user/README]]
would be a link to a file outside the Notebook's root (absolute path).Zim image link's tags
If
{{./image.png?href=.%2Fvideo.mkv&id=anchor-name&width=50}}
is inwiki-example.txt
,./
is resolved to the wiki page's attachment directorywiki-example
, and in Markor you would have something like:<a href="/home/user/Notebook/wiki-example/video.mkv"><img src="wiki-example/image.png" alt="wiki-example.txt" id="anchor-name" width="50" /></a>