Bug 430538 - Markdown files opened as plain text
Summary: Markdown files opened as plain text
Status: RESOLVED FIXED
Alias: None
Product: okular
Classification: Applications
Component: general (show other bugs)
Version: 21.12.3
Platform: Manjaro Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords:
: 431183 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-12-18 11:53 UTC by Yaroslav Sidlovsky
Modified: 2022-08-31 17:29 UTC (History)
11 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Markdown file for tests (1.66 KB, text/markdown)
2020-12-18 11:53 UTC, Yaroslav Sidlovsky
Details
Opens as markdown document (288 bytes, text/markdown)
2022-03-17 16:18 UTC, Adrian W.
Details
Doesn't open as markdown document (241 bytes, text/markdown)
2022-03-17 16:18 UTC, Adrian W.
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Yaroslav Sidlovsky 2020-12-18 11:53:03 UTC
Created attachment 134178 [details]
Markdown file for tests

SUMMARY
Okular uses wrong backend for Markdown files.
Issue could be fixed by the reverting this commit: https://invent.kde.org/graphics/okular/-/merge_requests/316/diffs?commit_id=d2ae2c283df3d42e72a964d8891e0915f8f3a94b.
Issue can't be reproduced with okular 20.08.3 (no other changes to the system was made).

STEPS TO REPRODUCE
1. Run "okular ~/Fedora-29-xrdp.md";
2. Check used backend in Help -> About Backend.

OBSERVED RESULT
"Txt backend" is used.


EXPECTED RESULT
"Markdown Backend" should be used instead.

SOFTWARE/OS VERSIONS
Operating System: Fedora 33
KDE Plasma Version: 5.20.4
KDE Frameworks Version: 5.77.0
Qt Version: 5.15.2
Kernel Version: 5.9.13-200.fc33.x86_64
OS Type: 64-bit
Processors: 4 × AMD FX(tm)-9590 Eight-Core Processor
Memory: 22.4 ГиБ of RAM
Graphics Processor: GeForce GTX 1060 6GB/PCIe/SSE2
Comment 1 Ilya Bizyaev 2020-12-18 11:57:53 UTC
Same here.

Okular 20.12
Frameworks 5.76.0
Qt 5.15.2
Comment 2 user6334 2020-12-18 12:25:16 UTC
Same here.

OS: Arch Linux x86_64
Kernel: 5.4.84-1-lts
KDE Plasma Version: 5.20.4
KDE Frameworks Version: 5.77.0
Qt Version: 5.15.2
Okular Version: 20.12.0
Comment 3 Bug Janitor Service 2020-12-19 23:50:01 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/okular/-/merge_requests/347
Comment 4 Albert Astals Cid 2020-12-27 01:10:51 UTC
Git commit 9e23338b002cd14d8a9ad191526a7950e72d97e9 by Albert Astals Cid.
Committed on 27/12/2020 at 00:16.
Pushed by aacid into branch 'release/20.12'.

Fix opening markdown files

In d2ae2c283df3d42e72a964d8891e0915f8f3a94b we introduced a tweak that
broke opening markdown files.

what we really want is this:
 * If the mimetype from the filename is text (or children) but looking
   at the data says it's not text, then try opening first opening with
   the data suggeted mimetype
 * But if the data suggested mimetype says it's text, use the filename
   suggested mimetype since for example, the only way to really
   differentiate markdown from text is the filename, so trust that

M  +4    -2    part/part.cpp

https://invent.kde.org/graphics/okular/commit/9e23338b002cd14d8a9ad191526a7950e72d97e9
Comment 5 Marcelo Jimenez 2021-01-05 16:55:33 UTC
*** Bug 431183 has been marked as a duplicate of this bug. ***
Comment 6 Simone Lazzaris 2021-11-26 09:26:04 UTC
I'm reopening this bug as I've got the same behavior in the newer version (21.08.3).

OS: Arch Linux x86_64
Kernel: 5.15.3-arch1-1
KDE Plasma Version: 5.23.3
KDE Gear: 21.08.3
Qt Version: 5.15.2
Okular Version: 21.08.3
Comment 7 Albert Astals Cid 2021-11-26 23:32:03 UTC
The attached file works, so you'll have to give us one that doesn't
Comment 8 Simone Lazzaris 2021-11-29 09:35:44 UTC
After an update and a reboot, it started to work for me too.
Sorry for the fuss.
Comment 9 Adrian W. 2022-03-17 16:17:16 UTC
I have a lot of markdown documents opening with the Txt backend. Figured it out eventually, it seems to me like it's a bug.

Attached 2 files, one opens with the Txt backend and the other with the Markdown backend.
- Both are 'mime-type: text/plain'
- Both show in Dolphin as 'Type: Markdown document' (*.md)

But Dolphin properties show different recognized content:
'markdown.md' shows correctly 'Content: plain text document'
'notmarkdown.md' shows incorrectly 'Content: MATLAB file'

The difference that triggers the content to be misdiagnosed is how the first line starts. Remove the first line from 'markdown.md' and the content changes to MATLAB document, consequently opening the file in Okular with the Txt backend.
Comment 10 Adrian W. 2022-03-17 16:18:19 UTC
Created attachment 147560 [details]
Opens as markdown document
Comment 11 Adrian W. 2022-03-17 16:18:54 UTC
Created attachment 147561 [details]
Doesn't open as markdown document
Comment 12 Bug Janitor Service 2022-08-21 17:18:53 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/okular/-/merge_requests/645
Comment 13 Albert Astals Cid 2022-08-31 17:29:20 UTC
Git commit 01871fdfff9363af3a90959650ef20ab9276c464 by Albert Astals Cid.
Committed on 31/08/2022 at 16:55.
Pushed by aacid into branch 'release/22.08'.

Even more tweaks to opening "text" files
Related: bug 456434

M  +10   -1    part/part.cpp

https://invent.kde.org/graphics/okular/commit/01871fdfff9363af3a90959650ef20ab9276c464