[Qt-creator] QtCreator Markdown Plugin

Eike Ziller Eike.Ziller at qt.io
Wed Apr 14 09:52:06 CEST 2021

> On Apr 12, 2021, at 17:51, ahmet erdinc yilmaz <ahmeterdincyilmaz at gmail.com> wrote:
> I'm very glad to hear that you liked the plugin, thank you!
> As discussed in https://forum.qt.io/topic/124822/qtcreator-markdown-plugin, I really want that it is included QtCreator by default, but I don't know whether it is possible or not for the following reasons:
> - Plugin depends on qtwebengine and qtwebchannel modules which do not ship with the QtCreator by default.
> - Plugin uses javascript for parsing markdown. 
> Also I really did not want to add these dependencies. As Cristian mentioned the c++ alternatives, I tried c++ markdown parsers at first. I played with "https://github.com/progsource/maddy" but at the very first examples they failed. I did not find any c++ parser that maintained properly. Then I find "https://github.com/markedjs/marked" (js markdown parser) which is  highly maintained and used. It has many tests which are actively developed. Then I realized that it is not an easy task. Markedjs is being maintained by 126 developers and used by 603k clients. Also has 24.8k stars. This library is really mature (By the way, I hate javascript). Then, I quit my C++ markdown parser dream. Therefore, I forked markedjs (https://github.com/erdinc09/marked) and added line number data to the rendered html nodes as html attribute in order to use it in synchronization of the editor and preview. If I followed other options than the plugin would be useless. I also used "highlightjs" for code syntax highlighting in preview. It is also as mature as markedjs. As a bonus, If I have any parsing or highlighting bug I can get it fixed very easily.
> And another advantage that comes with webengie, since the parsing is in the engine process you don't need to code for extra parsing thread and synchronization of data. Less code, less headache I think. 
> As litehtml html rendering option there are following problems (IMHO):
>  - It is not a javascript engine, therefore we cannot use markedjs, highlightjs and  we can not use javascipt DOM API to synch the preview and editor.

That is definitely correct :)

>  - It is not fully compatible with HTML/CSS standards.

I’d say that doesn’t matter much, since the preview in Qt Creator will probably use pretty simple HTML/CSS which works perfectly fine.

>  - If I understand correctly, for drawing texts, images, fonts we need other libraries.

We use litehtml for Qt Creator’s help browser by default now. I wrote a frontend that uses litehtml to draw HTML to a QPainter, plus a simple widget that is used in the help browser, enhanced with text search, selection, and copy.
This is a library that can be used by Qt Creator plugins (when built with CMake) by adding QtCreator::qlitehtml to library dependencies.
Unfortunately not yet documented, but here’s
the library: https://code.qt.io/cgit/playground/qlitehtml.git/
how it is used in Qt Creator’s help plugin: https://code.qt.io/cgit/qt-creator/qt-creator.git/tree/src/plugins/help/litehtmlhelpviewer.cpp

>  In my professional coding time (to earn money :-( ), I use IDEs Intellij and vscode mainly since I am a JVM (java, kotlin, xtext...) developer (by the way, my favorite is C++, Qt and QtCreator. Really!). All these IDEs have these features, developers like them. I felt uncomfortable when I used my plugin without any feature that I mentioned. For example, without scroll synchronization after your md file gets bigger, you start to get angry. 

Scroll synchronization is a big plus, indeed.

Br, Eike

> I like Qt and Qt Community, I will be so happy if I can help them. I really want to upstream plugin but I know that it is not an easy decision when it comes to dependencies. As I explained, I really tried  not to add them but I can not find any other useful and maintainable option. It is your decision and which decision is made, I want to help QtCreator become more beautiful! Yes, she is very beautiful :-).
>  If your decision is not to upstream, then I want your ideas about automatic downloading dependencies. Then it will be more useful.
>  Best regards,
>  //Erdinç
> On Mon, Apr 12, 2021 at 3:36 PM Cristian Adam <cristian.adam at qt.io> wrote:
> Hi,
> This plugin has a dependency on QtWebEngine, not because it needs to display html text, but because of the javascript libraries that are used to convert from markdown to html.
> A simple websearch after markdown and c++ pointed me to: https://stackoverflow.com/questions/889434/markdown-implementations-for-c-c
> I would love to have such a plugin in Qt Creator, since now https://github.com/cloose/CuteMarkEd to edit markdown files outside Qt Creator. 
> I think litehtml should suffice to display the html rendered by a markdown parser. 
> Cheers,
> Cristian.
> On 19/03/2021 09:17, ahmet erdinc yilmaz wrote:
>> Hi all,
>> I have been developing a markdown plugin for QtCreator. I think it is time to announce :-). You can reach from https://github.com/erdinc09/MarkdownEditView.
>> I also published releases for all three platforms. I hope you like it.
>> Features:
>> 	• Syntax highlighting in editor
>> 	• Html preview
>> 	• Code highlighting in preview
>> 	• Theme aware preview and editor
>> 	• Bidirectional vertical scroll synchronization between editor and preview
>> Dark Theme:
>> <dark.jpg>
>> Classic Theme:
>> <classic.jpg>
>> I have already announced it on the forum.qt.io.
>> Best regards,
>> // Erdinç
>> _______________________________________________
>> Qt-creator mailing list
>> Qt-creator at qt-project.org
>> https://lists.qt-project.org/listinfo/qt-creator
> _______________________________________________
> Qt-creator mailing list
> Qt-creator at qt-project.org
> https://lists.qt-project.org/listinfo/qt-creator

Eike Ziller
Principal Software Engineer

The Qt Company GmbH
Erich-Thilo-Straße 10
D-12489 Berlin
eike.ziller at qt.io
Geschäftsführer: Mika Pälsi,
Juha Varelius, Jouni Lintunen
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B

More information about the Qt-creator mailing list