76 lines
1.7 KiB
C++
76 lines
1.7 KiB
C++
#ifndef CTAIMATHCONVERT_H
|
|
#define CTAIMATHCONVERT_H
|
|
|
|
// 然后包含 cmark-gfm 相关头文件
|
|
#include "cmark-gfm.h"
|
|
#include "cmark-gfm-extension_api.h"
|
|
#include "cmark-gfm-core-extensions.h"
|
|
|
|
// Qt 相关头文件
|
|
#include <QObject>
|
|
#include <QDebug>
|
|
#include <QPainter>
|
|
#include <QPixmap>
|
|
#include <QDir>
|
|
#include <QFile>
|
|
#include <QMessageBox>
|
|
#include <QBuffer>
|
|
#include <QUuid>
|
|
#include <QRegularExpression>
|
|
#include <QRegularExpressionMatchIterator>
|
|
|
|
// LaTeX 相关头文件
|
|
#include "latex.h"
|
|
#include "platform/qt/graphic_qt.h"
|
|
|
|
// 项目相关头文件
|
|
#include "ctai_base.h"
|
|
|
|
class TexGuard {
|
|
public:
|
|
TexGuard() {
|
|
tex::LaTeX::init();
|
|
}
|
|
|
|
~TexGuard() {
|
|
tex::LaTeX::release();
|
|
}
|
|
};
|
|
|
|
using namespace tex;
|
|
|
|
class ctaiMathConvert :public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit ctaiMathConvert();
|
|
~ctaiMathConvert();
|
|
QString replace_tags_svg(const QString &text,int font_size);
|
|
void set_convert_opts();
|
|
void save_svg(QPixmap& img);
|
|
|
|
private:
|
|
void debug_latex_match(const QString &text, const QRegularExpressionMatch &match);
|
|
QString clean_latex_for_mula(const QString &formula);
|
|
QString math_convert_svg(const QString& text);
|
|
QByteArray svg_to_base64(QPixmap& pix);
|
|
QString markdown_to_html(const QString& text);
|
|
QString fix_img_str_line_height(QString html);
|
|
TexGuard texGuard;
|
|
//宽度
|
|
int m_render_width=600;
|
|
int m_render_height=64;
|
|
//文本大小
|
|
int m_text_size=16;
|
|
//行距
|
|
float m_lineSpace=1.5f;
|
|
//颜色
|
|
tex::color m_color=0xff424242;
|
|
//边距
|
|
int m_padding=3;
|
|
//处理后保存模式
|
|
bool save_mode=false;
|
|
|
|
};
|
|
|
|
#endif |