code format
This commit is contained in:
@@ -1,36 +1,36 @@
|
||||
#include "markdown.h"
|
||||
#include <QIODevice>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QIODevice>
|
||||
#ifndef NO_MARKDOWN
|
||||
extern "C" {
|
||||
#include MARKDOWN_HEADER
|
||||
# include MARKDOWN_HEADER
|
||||
}
|
||||
#ifndef mkd_flags_are
|
||||
# ifndef MKD_DLEXTRA
|
||||
# define MKD_DLEXTRA 0x01000000
|
||||
# ifndef mkd_flags_are
|
||||
# ifndef MKD_DLEXTRA
|
||||
# define MKD_DLEXTRA 0x01000000
|
||||
# endif
|
||||
# ifndef MKD_FENCEDCODE
|
||||
# define MKD_FENCEDCODE 0x02000000
|
||||
# endif
|
||||
# ifndef MKD_EXTRA_FOOTNOTE
|
||||
# define MKD_EXTRA_FOOTNOTE 0x00200000
|
||||
# endif
|
||||
# ifndef MKD_TOC
|
||||
# define MKD_TOC 0x00001000
|
||||
# endif
|
||||
# ifndef MKD_AUTOLINK
|
||||
# define MKD_AUTOLINK 0x00004000
|
||||
# endif
|
||||
# ifndef MKD_GITHUBTAGS
|
||||
# define MKD_GITHUBTAGS 0x08000000
|
||||
# endif
|
||||
# endif
|
||||
# ifndef MKD_FENCEDCODE
|
||||
# define MKD_FENCEDCODE 0x02000000
|
||||
# endif
|
||||
# ifndef MKD_EXTRA_FOOTNOTE
|
||||
# define MKD_EXTRA_FOOTNOTE 0x00200000
|
||||
# endif
|
||||
# ifndef MKD_TOC
|
||||
# define MKD_TOC 0x00001000
|
||||
# endif
|
||||
# ifndef MKD_AUTOLINK
|
||||
# define MKD_AUTOLINK 0x00004000
|
||||
# endif
|
||||
# ifndef MKD_GITHUBTAGS
|
||||
# define MKD_GITHUBTAGS 0x08000000
|
||||
# endif
|
||||
#endif
|
||||
|
||||
static QString markdown_css = "table { margin: 5px; background-color: #cccccc; }"
|
||||
"table tr { background-color: white; }"
|
||||
"table td { vertical-align: middle; padding: 5px;}"
|
||||
"table th { padding: 5px; };"
|
||||
;
|
||||
static QString markdown_css = "table { margin: 5px; background-color: #cccccc; }"
|
||||
"table tr { background-color: white; }"
|
||||
"table td { vertical-align: middle; padding: 5px;}"
|
||||
"table th { padding: 5px; };";
|
||||
|
||||
QString md2html(const QByteArray & src) {
|
||||
static bool _is_mkd_init = false;
|
||||
@@ -39,34 +39,34 @@ QString md2html(const QByteArray & src) {
|
||||
_is_mkd_init = true;
|
||||
mkd_initialize();
|
||||
}
|
||||
#ifdef _MARKDOWN_D
|
||||
# ifdef _MARKDOWN_D
|
||||
DWORD flagm = (MKD_DLEXTRA | MKD_FENCEDCODE);
|
||||
Document
|
||||
#endif
|
||||
#ifdef _MKDIO_D
|
||||
#ifdef mkd_flags_are
|
||||
mkd_flag_t * flagm = mkd_flags();
|
||||
mkd_set_flag_num(flagm, MKD_DLEXTRA);
|
||||
mkd_set_flag_num(flagm, MKD_FENCEDCODE);
|
||||
#else
|
||||
mkd_flag_t flagm = (MKD_DLEXTRA | MKD_FENCEDCODE | MKD_GITHUBTAGS | MKD_AUTOLINK);
|
||||
#endif
|
||||
# endif
|
||||
# ifdef _MKDIO_D
|
||||
# ifdef mkd_flags_are
|
||||
mkd_flag_t * flagm = mkd_flags();
|
||||
mkd_set_flag_num(flagm, MKD_DLEXTRA);
|
||||
mkd_set_flag_num(flagm, MKD_FENCEDCODE);
|
||||
# else
|
||||
mkd_flag_t flagm = (MKD_DLEXTRA | MKD_FENCEDCODE | MKD_GITHUBTAGS | MKD_AUTOLINK);
|
||||
# endif
|
||||
MMIOT
|
||||
#endif
|
||||
* doc = mkd_string(src.constData(), src.size(), 0);
|
||||
# endif
|
||||
*doc = mkd_string(src.constData(), src.size(), 0);
|
||||
if (!doc) return QString();
|
||||
mkd_compile(doc, flagm);
|
||||
char * html = 0;
|
||||
int len = mkd_document(doc, &html);
|
||||
int len = mkd_document(doc, &html);
|
||||
if (!html) {
|
||||
mkd_cleanup(doc);
|
||||
return QString();
|
||||
}
|
||||
QString ret = QString::fromUtf8(html, len);
|
||||
mkd_cleanup(doc);
|
||||
QString title = QTextStream(&ret, QIODevice::ReadOnly).readLine();
|
||||
title = title.mid(title.indexOf(">")+1);
|
||||
title = title.left(title.indexOf("<"));
|
||||
QString title = QTextStream(&ret, QIODevice::ReadOnly).readLine();
|
||||
title = title.mid(title.indexOf(">") + 1);
|
||||
title = title.left(title.indexOf("<"));
|
||||
QString header = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
|
||||
"<html>\n<head>\n"
|
||||
"<meta name=\"qrichtext\" content=\"1\" />\n"
|
||||
|
||||
@@ -1,28 +1,29 @@
|
||||
/*
|
||||
QAD - Qt ADvanced
|
||||
QAD - Qt ADvanced
|
||||
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
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 Lesser General Public License for more details.
|
||||
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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef QAD_MARKDOWN_H
|
||||
#define QAD_MARKDOWN_H
|
||||
|
||||
#include <QString>
|
||||
#include "qad_doc_export.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
|
||||
QAD_DOC_EXPORT QString md2html(const QByteArray & src);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user