Bug 390210 - KMarkdownWebView: add support for comments
Summary: KMarkdownWebView: add support for comments
Status: RESOLVED UPSTREAM
Alias: None
Product: kmarkdownwebview
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 0.4.0
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: Friedrich W. H. Kossebau
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-02-10 12:19 UTC by Gregor Mi
Modified: 2018-02-12 19:33 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gregor Mi 2018-02-10 12:19:50 UTC
There seems to no standard way to add comments to a Markdown file.

I tried the two methods presented here (https://alvinalexander.com/technology/markdown-comments-syntax-not-in-generated-output)

1. HTML comments: <!--    this is a an html comment. -->
2. Special trick: [//]: # (This syntax works like a comment, and won't appear in any output.)

Both currently don't work in the KMarkdownWebView. Which is ok because they are non-standard. Though, the HTML style comments I find rather useful.
Comment 1 Friedrich W. H. Kossebau 2018-02-10 12:51:49 UTC
The parsing of the markdown is done by code from another project, marked. KMarkdownWebView is just a simple hack to bind together other existing code (see https://cgit.kde.org/kmarkdownwebview.git/about/ for more details).

So this would need to be fixed in the upstream projects.

I though just saw there is some new release of marked out, will see to do a new release of KMarkdownWebView in the next weeks with an updated copy (and also extend the buildsystem to allow packagers to pick up packaged versions of marked).
Comment 2 Gregor Mi 2018-02-10 19:59:51 UTC
There is an online version of marked: http://www.javascriptoo.com/marked

I entered this code on the left side:

```
<!DOCTYPE html>
<html lang="en">
<head>
    <title>marked example</title>
    <script src="/application/html/js/chjj/marked/marked.js"></script>
</head>
<body>
    <div id="results"></div>
    <script>
        document.getElementById('results').innerHTML = (marked(
`this is __markdown__ 
<!-- hasdflj -->
                                                               
Hallo`));
    </script>
</body>
</html>

```

The comment is NOT shown on the rendered right side. So, in principle it should work.
Comment 3 Friedrich W. H. Kossebau 2018-02-11 18:42:37 UTC
I am slightly confused now. I have to tell I had not tested before what you initially said in this bug report, but now I did: and both comment codes work for me when I try them with KMarkdownWebView 0.4.0.

Example:
When editing a file test.md in Kate with the content below and looking at the preview using KMarkdownWebView KParts plugin, both comments are not shown, only the before and after texts:
---- 8< ----
# Testing comments

## HTML comment
Before the comment.
<!--    this is a an html comment. -->
After the comment.

## Markdown comment

Before the comment.
[//]: # (This syntax works like a comment, and won't appear in any output.)
After the comment.
---- 8< ----

Can you tell how to reproduce that this does not work? Please give an example file and tell with which application loading the KMarkdownWebView KParts plugin to show the file it does not work.

In other news, your report had triggered me to do a new release 0.5.0 as I found during that there is a new version of marked. The release is currently on the way to the download servers, so should be picked up by packagers soon. So something has already been coming out of this :)
But then I tested the Markdown comment code also with the current 0.4.0 version and saw it working there as well. Now your turn again :)
Comment 4 Gregor Mi 2018-02-12 19:33:08 UTC
My fault, I gave a false example. This example is the one that does not work because it involves a markdown heading:

<!-- test
====
-->

I reported the issue here, including a screenshot: https://github.com/chjj/marked/issues/1050

> In other news, your report had triggered me to do a new release 0.5.0 as I
> found during that there is a new version of marked. The release is currently
> on the way to the download servers, so should be picked up by packagers
> soon. So something has already been coming out of this :)
This is good news. :)