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

Package - Images in description aren't being displayed at all #337

Open
Tomblarom opened this issue Nov 12, 2023 · 13 comments
Open

Package - Images in description aren't being displayed at all #337

Tomblarom opened this issue Nov 12, 2023 · 13 comments

Comments

@Tomblarom
Copy link

According to the used function QTextDocument::setMarkdown(..) in vesc_tool/main.cpp, the complete MarkdownDialectGitHub is supported, including images.

However when compiling the description file, this formatting results in "not found images":

..
![Locate Connector](location_plug.png)
..
![Locate Connector](https://i.imgur.com/O3OCuwo.jpg)
..

image

When generating the description and saving the package with VESC-Tool, it includes the images perfectly fine.

@Tomblarom
Copy link
Author

Same issue for code snippets, like in Code Server... @vedderb haven't you noticed that yet in your own packages?

image
image

@vedderb
Copy link
Owner

vedderb commented Nov 13, 2023

Can you try with the latest beta? The markdown-support in Qt is not that good and in the latest beta I'm trying to manually parse it and generate html from it instead. It should work better for code blocks, but I'm not sure if https-images work for all platforms. Http should work.

@Tomblarom
Copy link
Author

Tomblarom commented Nov 14, 2023

Saw your commit, great that there is such a library as maddy!

For code-blocks, yes they are working now :)
For https-images on Windows, yes it does also load from https! Is there a chance to include images in the package, as local resource, rather than external? Might be a little bit overkill, but images help a lot to explain stuff visually.

@vedderb
Copy link
Owner

vedderb commented Nov 14, 2023

I can have a look at that.

Regarding maddy, I rewrote six of the parsers, but that is not visible in the commit unfortunately. The image parser has image caching support now:
https://github.com/vedderb/vesc_tool/blob/master/maddy/imageparser.h

I also spent a lot of work on the codeblock parser and I rewrote four others as they were super slow
progsource/maddy#50 (comment)

For QMarkdownEdit I fixed one bug that made it crash during some of the edit operations and I added support for changing the colors of everything depending on the vesc tool theme.

@Tomblarom
Copy link
Author

Resizing is not working yet. It tried to use HTML <img src=".." alt=".." width="300"/>.

@vedderb
Copy link
Owner

vedderb commented Nov 14, 2023

This is what you can get working in the Qt editors:
https://doc.qt.io/qt-6/richtext-html-subset.html#block-attributes
You can see that img does not support the resize attribute. I can maybe fix that too by updating the image-parser to resize the image before caching it, but best is to scale the image to the correct size from the start.

@vedderb
Copy link
Owner

vedderb commented Nov 14, 2023

I tested the list now, it works for me. Do you have a way to reproduce the problem?

@Tomblarom
Copy link
Author

Tomblarom commented Nov 14, 2023

Do you have a way to reproduce the problem?

The issue was on my side, therefor I deleted it. The line before 1. contained a space.

@Tomblarom
Copy link
Author

btw, loading existing packages into VESC Tool under "Create Package" is broken currently. :(

image
image

Loading on "Load Custom" works fine :)

@vedderb
Copy link
Owner

vedderb commented Nov 14, 2023

That happens because I broke compatibility a bit with old packages by storing the raw data as markdown instead of html. I will add some code to detect if it is an old package and load the text as html instead.

Regarding images, I think I can embed them in the packages so that they are stored locally. It is a bit tricky to make that work so that github also renders the images correctly, but I think it can be done with some clever caching.

@vedderb
Copy link
Owner

vedderb commented Nov 14, 2023

This fix should allow opening old packages properly: 1275db4

I have also added a markdown preview that is updated live next to the markdown editor:

bild

The beta is updated now.

@Tomblarom
Copy link
Author

I tried your new editor with a .vescpkg that has been created with the previous version of VESC-Tool "Create Package". I send you the file.

I experience that the live-updates are very slow (1-2s), because it has an embedded image which is not beeing rendered, but shown as: ![image](data:image/13196.PNG;base64,i VBORw0KGgoAAAANSU.....hEUgAAAfQSUVORK5CYII=). Page "Load Custom" renders it correctly.

I'm running Windows 10 21H2 and do compile using Qt Creator 11.0.3, Qt 5.15.2, MinGW 8.1.0 64-bit and CMake 3.24.2. I also tried to make a release with windeployqt build-vesc_tool-Desktop_Qt_5_15_2_MinGW_64_bit-Release\release, but same outcome.

And the order of generated Markdown-symbols are a little bit mixed in page "Create Package": **_Locate Connector**_ instead of **_Locate Connector_**

Code block generation is like this:
image

@vedderb
Copy link
Owner

vedderb commented Nov 16, 2023

Conversion to markdown will not be perfect from old packages, it is mostly a help to transition from them to markdown. Base64 for the images (which was used before) will also not work that well with markdown. The load package page will work better in comparison as it does not try to convert it to markdown.

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

No branches or pull requests

2 participants