You are browsing as a guest. Sign up (or log in) to start making projects!

1h 33m 14s logged

I just added some nice features to MDEZ++! These are very important features for a Markdown editor.
​
The first feature, which is very obvious to any user, is the added ability to print the current document. If you are wondering, this is obviously to a physical printer. Not a 3D Printer. (I just had to make sure that distinction was made).
​
The second feature, which is also obvious to any user, is the ability to export the current document to an HTML file, instead of just a Markdown file. I really don’t need to explain this much.
​
The third feature is easier said than done. Previously, blockquotes had no special coloring. This is just because of the way Qt rendered the Markdown to HTML. I in no means have any experience in any sort of regexing. Here is the code I had to add to make this work.

    QString mdText = editor->toPlainText();

    QTextDocument tempDoc;
    tempDoc.setMarkdown(mdText);
    QString rawHtml = tempDoc.toHtml();

    QRegularExpression qtBlockquoteRegex("<p style=\" margin-top:[^;]+; margin-bottom:[^;]+; margin-left:40px; margin-right:40px; [^\"]*\">(.*?)</p>");

    QString tableReplacement =
        "<table width=\"100%\" cellpadding=\"8\" style=\"margin: 6px 0px;\">"
        "<tr><td bgcolor=\"#f0f0f0\" style=\"border-left: 4px solid #007acc;\">"
        "<span style=\"color: #555555;\">\\1</span>"
        "</td></tr>"
        "</table>";

    rawHtml.replace(qtBlockquoteRegex, tableReplacement);
0
43

Comments 0

No comments yet. Be the first!