/* * qtmaildir - a Qt6 mail client for notmuch-indexed Maildirs * Copyright (C) 2026 Danilo M. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ // cmark-gfm's headers are C and carry no Qt interaction, so the gmime // include-order rule does not apply here. They still go first, for consistency // with mimeparser.cpp. #include #include #include "markdownrenderer.h" #include #include namespace { /// The extensions this application enables, by cmark-gfm's own names. /// /// `table` is absent deliberately, not by oversight: tables render badly /// across mail clients regardless of who generates them. `tagfilter` is absent /// because safe mode (see below) already suppresses raw HTML wholesale, which /// is the stronger measure. const char *const kExtensions[] = { "autolink", "strikethrough", "tasklist" }; } // namespace QString MarkdownRenderer::toHtml(const QString &markdown) { if (markdown.isEmpty()) return {}; // Idempotent and required before cmark_find_syntax_extension() can resolve // any name. Calling it per render rather than once at startup keeps this // function free of initialisation order concerns; it is a hash lookup // after the first call. cmark_gfm_core_extensions_ensure_registered(); // CMARK_OPT_DEFAULT is 0, and CMARK_OPT_SAFE is a NO-OP in cmark-gfm 0.29: // safe mode has been the default since that release, and the flag is kept // only for API compatibility with code written against older versions. // The real requirement is that CMARK_OPT_UNSAFE must never be set. Under // safe mode a raw