2017-03-29 10:18:37 +00:00
|
|
|
#ifndef MDHIGHLIGHTER_H
|
|
|
|
#define MDHIGHLIGHTER_H
|
|
|
|
|
|
|
|
#include <QSyntaxHighlighter>
|
|
|
|
|
|
|
|
#include <QHash>
|
|
|
|
#include <QTextCharFormat>
|
2019-10-13 14:59:12 +00:00
|
|
|
#include <QRegularExpression>
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
class QTextDocument;
|
|
|
|
|
|
|
|
class MdHighlighter : public QSyntaxHighlighter
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2018-05-04 07:58:32 +00:00
|
|
|
explicit MdHighlighter(QTextDocument *parent = nullptr);
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void highlightBlock(const QString &text);
|
|
|
|
|
|
|
|
private:
|
2021-01-24 14:50:13 +00:00
|
|
|
struct HighlightingRule
|
|
|
|
{
|
2019-10-13 14:59:12 +00:00
|
|
|
QRegularExpression pattern;
|
2017-03-29 10:18:37 +00:00
|
|
|
QTextCharFormat format;
|
|
|
|
};
|
|
|
|
QVector<HighlightingRule> highlightingRules;
|
|
|
|
|
|
|
|
QTextCharFormat keywordFormat;
|
|
|
|
QTextCharFormat classFormat;
|
|
|
|
QTextCharFormat singleLineCommentFormat;
|
|
|
|
QTextCharFormat multiLineCommentFormat;
|
|
|
|
QTextCharFormat quotationFormat;
|
|
|
|
QTextCharFormat functionFormat;
|
|
|
|
};
|
|
|
|
|
2021-01-24 14:50:13 +00:00
|
|
|
#endif // MDHIGHLIGHTER_H
|