Bug 410087 - Kate preview plugin doesn't render Markdown with kmarkdownwebview plugin installed
Summary: Kate preview plugin doesn't render Markdown with kmarkdownwebview plugin inst...
Status: RESOLVED WORKSFORME
Alias: None
Product: kmarkdownwebview
Classification: Frameworks and Libraries
Component: kpart (show other bugs)
Version: unspecified
Platform: Neon Linux
: NOR normal
Target Milestone: ---
Assignee: Friedrich W. H. Kossebau
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-21 22:49 UTC by John S.
Modified: 2023-10-24 15:15 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Kate on Neon doesn't show preview for .md file (195.52 KB, image/png)
2021-08-13 16:46 UTC, Andrey E.
Details
VS Code plugin works correctly, Okular with kmarkdownwebview has issues (269.54 KB, image/png)
2021-08-13 16:50 UTC, Andrey E.
Details

Note You need to log in before you can comment on or make changes to this bug.
Description John S. 2019-07-21 22:49:19 UTC
SUMMARY
I'm unable to view a preview of any Markdown document using kmarkdownwebview. I've ensured that kmarkdownwebview is installed correctly and is functioning (thumbnails are generated in Dolphin when kmarkdownwebview is built with -DUSE_QTWEBKIT=TRUE). I was able to get a preview of one document immediately after building kmarkdownwebview, but after closing Kate and reopening it, I'm unable to get a preview. This problem persists if I remove and reinstall kmarkdownwebview.

STEPS TO REPRODUCE
1. Clone kmarkdownwebview repository: git clone https://github.com/KDE/kmarkdownwebview.git
2. Enter the new directory: cd kmarkdownwebview
3. Get the latest stable version: git checkout tags/v0.5.5
4. Configure kmarkdownwebview: cmake -DKDE_INSTALL_USE_QT_SYS_PATHS=TRUE -DUSE_QTWEBKIT=TRUE .
5. Build: make
6. Install: sudo make install
7. Set kmarkdownwebview as embedded Markdown viewer: Plasma settings > Applications > File Associations > text/markdown > Embedding > move Markdown Web View (kmarkdownwebviewpart) to the top
8. Open an existing Markdown file in Kate with preview plugin enabled

OBSERVED RESULT
Preview panel stays blank except for a "No preview available" message


EXPECTED RESULT
Preview panel renders a web view version of the current Markdown document.


SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Fedora 30
KDE Plasma Version: 5.15.5
KDE Frameworks Version: 5.59.0
Qt Version: 5.12.4

ADDITIONAL INFORMATION
Comment 1 Friedrich W. H. Kossebau 2019-07-21 22:58:51 UTC
Hi. Just to make sure, you are not running into bug 384971, bug 384972 or 384973? Does using the Okular plugin (which has a markdown import plugin and thus also can be used here) work instead?
Comment 2 John S. 2019-07-21 23:08:51 UTC
I just tested and I'm unable to get the Okular plugin to work either. However, this is not the initial blank document that hasn't been saved (bug 384971) and I'm not attempting to change the MIME type of an existing document to Markdown (bug 384972). The workarounds for bug 384973 don't work for me either.
Comment 3 Friedrich W. H. Kossebau 2019-07-21 23:17:41 UTC
Potentially in newer versions this could also be influenced by the Mode currently used (cmp. https://cgit.kde.org/kate.git/tree/addons/preview/previewwidget.cpp#n169 )

So test if changing the Tools>Mode to Markup > Markdown fixes things.

Otherwise no idea, no longer a maintainer of that plugin (surprised to have been subscribed).
Comment 4 John S. 2019-07-21 23:21:21 UTC
Just tried that, still no luck. Is there a way to get debug output from the preview plugin? I see what looks like debug text in the source you linked but if I launch Kate from a terminal window I don't get any debug output.
Comment 5 Friedrich W. H. Kossebau 2019-07-21 23:30:55 UTC
(In reply to jman012345 from comment #4)
> Just tried that, still no luck. Is there a way to get debug output from the
> preview plugin? I see what looks like debug text in the source you linked
> but if I launch Kate from a terminal window I don't get any debug output.

You can control the debug level via the qt logging system. In this case the identifier to use is a (badly unnamespaced) "ktexteditorpreviewplugin".

export QT_LOGGING_RULES="ktexteditorpreviewplugin.debug=true"
should set the respective env var to change the level for that logging category.
(more background at https://doc.qt.io/qt-5/qloggingcategory.html)
Comment 6 John S. 2019-07-24 14:22:17 UTC
Alright, I've figured out what the problem is, and it's a variant/duplicate of bug 384973.

As it turns out, even if you open a Markdown document, close it, and reopen it, to Kate (or the preview plugin) that's no different than opening a Markdown document from Kate just having been opened. The workaround is either to open one document, then open your Markdown document with the first one still open, then close the first document; or to type a few letters into the initial untitled document, then open your desired Markdown document, then close the untitled document.
Comment 7 Justin Zobel 2020-10-30 03:56:52 UTC
John I've just tested on kate from git master and when opening kate from scratch and then opening a .md file I get a preview instantly.

Can you please test and confirm if this bug is still occurring, thanks.
Comment 8 Bug Janitor Service 2020-11-14 04:33:52 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 9 Bug Janitor Service 2020-11-29 04:33:49 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!
Comment 10 Andrey E. 2021-08-13 16:46:25 UTC
Created attachment 140693 [details]
Kate on Neon doesn't show preview for .md file

STEPS TO REPRODUCE
1. Install Kate and kmarkdownwebview
2. Open Kate by console command and open any non-empty .md file
3. Try to open preview

OBSERVED RESULT
1. Empty space instead of preview
2. Errors in console log:
Qt WebEngine seems to be initialized from a plugin. Please set Qt::AA_ShareOpenGLContexts using QCoreApplication::setAttribute before constructing QGuiApplication.
WebEngineContext used before QtWebEngine::initialize() or OpenGL context creation failed.

EXPECTED RESULT
Kate shows preview

SOFTWARE/OS VERSIONS
Operating System: KDE neon 5.22
KDE Plasma Version: 5.22.4
KDE Frameworks Version: 5.84.0
Qt Version: 5.15.3
Kernel Version: 5.11.0-25-generic (64-bit)
Graphics Platform: X11
Processors: 6 × AMD Ryzen 5 4500U with Radeon Graphics
Memory: 5.7 ГиБ of RAM
Graphics Processor: AMD RENOIR

ADDITIONAL INFORMATION
Okular also has the same problems
kmarkdownwebview 0.5.6-0xneon+20.04+focal+release+build7
Comment 11 Andrey E. 2021-08-13 16:50:51 UTC
Created attachment 140694 [details]
VS Code plugin works correctly, Okular with kmarkdownwebview has issues

The second screenshot for comparison: VS Code has specific Preview plugin which works correctly.
Okular with kmarkdownwebview has issues.
AFAIR, Okular without kmarkdownwebview shows plain text.
Comment 12 jmaspons 2021-09-02 14:24:29 UTC
Uninstalling kmarkdownwebview and installing markdownpart solves the problems in Neon and I don't find any regression in kate nor okular
Comment 13 Roger 2021-10-17 23:47:30 UTC
I confirm exactly the same behavior and error messages as in Andrey's Comment 10 above.
Comment 14 Roger 2021-10-18 00:19:01 UTC
Ok, jmaspons' suggestion in Comment 12, along with the instructions below, solved the problem.

"To use the MarkdownPart KParts plugin in a KParts-using applications, often you will need to configure that globally in the Plasma System Settings, and there in the "File Associations" page. Select the MIME type "text/markdown" and in the "Embedding" tab in the "Service Preference Order" group make sure "Markdown View (markdownpart)" is on top of the list."
Comment 15 Christoph Cullmann 2022-05-07 18:35:49 UTC
markdownpart works for me, the other one I can't comment on.
Comment 16 Lassi Väätämöinen 2023-10-24 15:15:51 UTC
Just tried this and after installing 'kmarkdownwebview' the Document Preview plugin works.

Kate Version 23.08.2
KMarkdownWebViewPart Version 0.5.6