scripts icon indicating copy to clipboard operation
scripts copied to clipboard

Markdown-it parser not showing images in preview

Open kc853 opened this issue 5 years ago • 7 comments

Hello, just tried the Markdown-it script and the preview doesn't show the images anymore.

Expected behaviour

Markdown-it parser shows images as the default parser

Actual behaviour

Default parser shows images in preview, Markdown-it does not. The HTML Export shows the image.

Steps to reproduce

Create note with ![Bild](https://www.servernoobs.com/wp-content/uploads/2012/01/Linux-3.jpg) and activate/deactivate Markdown-it script

Output from the debug section in the settings dialog

Version**: 20.2.11 Build date: Feb 26 2020 Build number: 5419 Platform: windows Operating System: Windows 10 (10.0) Build architecture: i386 Current architecture: x86_64 Release: AppVeyor Qt Version (build): 5.13.2 Qt Version (runtime): 5.13.2 Portable mode: no Settings path / key: \HKEY_CURRENT_USER\Software\PBE\QOwnNotes Application database path: C:\Users\Normal\AppData\Roaming\PBE\QOwnNotes\QOwnNotes.sqlite Application arguments: C:\Users\Normal\Desktop\QownNotes\QOwnNotes.exe Qt Debug: 0 Locale (system): de_DE Locale (interface): empty Primary screen resolution: 1920x1080 Icon theme: breeze-dark-qownnotes Notes in current note folder: 26 Calendar items: 0 Enabled scripts: 2

Enabled scripts

Script Merge selected notes

id: 1 path: C:\Users\Normal\AppData\Roaming\PBE\QOwnNotes\scripts\merge-notes\merge-notes.qml variablesJson:

{
    "pyCommand": "C:\\Users\\Normal\\AppData\\Local\\Programs\\Python\\Python38-32\\python.exe"
}

identifier: merge-notes version: 0.0.3 minAppVersion: 17.08.5

Script Markdown-it markdown parser

id: 3 path: C:\Users\Normal\AppData\Roaming\PBE\QOwnNotes\scripts\markdown-it\markdown-it.qml variablesJson:

{
    "customStylesheet": "table {border-spacing: 0; border-style: solid; border-width: 1px; border-collapse: collapse; margin-top: 0.5em;} th, td {padding: 0 50px;}",
    "options": "{\n    //html:         false,        // Enable HTML tags in source\n    //xhtmlOut:     false,        // Use '/' to close single tags (<br />)\n    //breaks:       false,        // Convert '\\n' in paragraphs into <br>\n    //langPrefix:   'language-',  // CSS language prefix for fenced blocks\n    //linkify:      false,        // autoconvert URL-like texts to links\n\n    // Enable some language-neutral replacements + quotes beautification\n    //typographer:  false,\n\n    // Double + single quotes replacement pairs, when typographer enabled,\n    // and smartquotes on. Could be either a String or an Array.\n    //\n    // For example, you can use '«»„“' for Russian, '„“‚‘' for German,\n    // and ['«\\xA0', '\\xA0»', '‹\\xA0', '\\xA0›'] for French (including nbsp).\n    //quotes: '\\u201c\\u201d\\u2018\\u2019', /* “”‘’ */\n\n    // Highlighter function. Should return escaped HTML,\n    // or '' if the source string is not changed and should be escaped externaly.\n    // If result starts with <pre... internal wrapper is skipped.\n    //\n    // function (/*str, lang*/) { return ''; }\n    //\n    //highlight: null,\n\n    //maxNesting:   100            // Internal protection, recursion limit\n}"
}

identifier: markdown-it version: 1.3 minAppVersion: 17.08.2

Relevant log output in the Log panel

nothing special

kc853 avatar Feb 26 '20 21:02 kc853

See: https://github.com/pbek/QOwnNotes/issues/1635#issuecomment-589522190

pbek avatar Feb 27 '20 05:02 pbek

And in case you are talking only about remote images... I don't think they ever where supported in markdown-it. I wrote a special in-memory-downloader for external images back then for the internal markdown2html process of QON.

pbek avatar Feb 27 '20 05:02 pbek

Just a note for anyone else searching for " Qownnotes doesn't display images when using markdown-it": it can be fixed by adding file:// in front, even though it's a relative path, ie: ![Test](file://media/1.jpg) works for media/1.jpg (sub under data).

I installed a bunch of scripts when I first installed QownNotes, without knowing the consequences. (Here, spending about an hour trying to figure out why I can't see images, no matter what.)

Since everything puts out the other type of link, I'm probably just going to disable the script, unless this behavior isn't by design and it's actually a bug.

cinereous avatar Jun 06 '20 09:06 cinereous

@cinereous, thank you. Is there anything you want to share as a pull request for the markdown-it script?

pbek avatar Jun 06 '20 11:06 pbek

No, I've just gone and left it disabled; hopefully if it's not something actually needed. I just installed a bunch of scripts when I installed Qownnotes, thinking they'd be needed for functionality (like, the markdown-it seemed more advanced?), but a lot of this just seems my unfamiliarity with the program.

For example, I also installed the 'insert TOC', since I really like having one, but there's an automatic (and updated) navigation on the side built-in, which makes the script seem somewhat unnecessary.

Using the web extension works brilliantly and captures images perfectly, when one doesn't unnecessarily install scripts that trash displaying the images in preview! :)

cinereous avatar Jun 06 '20 17:06 cinereous

Many scripts are for and by people that want to tinker with the behavior of stuff. The image preview of the html generated by the markdown-it script only works with the "legacy image links" any more. That's why I asked if anyone wants to fix that (since the author/s of the script didn't). 😁

pbek avatar Jun 07 '20 05:06 pbek

@milan-rusev, @bessw, does't anyone care to take a look at that? 😉

pbek avatar Oct 18 '20 11:10 pbek