-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstcSyntaxPatterns.cpp
More file actions
55 lines (53 loc) · 2.49 KB
/
stcSyntaxPatterns.cpp
File metadata and controls
55 lines (53 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "stcSyntaxPatterns.h"
namespace stc
{
namespace syntax
{
const QRegularExpression stdDefaultTagRe(R"(\[/?\w+(=[^\]]+)?\])");
// DIV
const QRegularExpression divOpenRe(R"___(\[(div)(?:\s+class="(tip|uwaga)")?\]|\[(cytat)\])___");
const QRegularExpression divCloseRe(R"___(\[/div\]|\[/cytat\])___");
// PKT / CSV
const QRegularExpression pktOpenRe(R"(\[pkt(\s+[^\]]*)?\])");
const QRegularExpression pktCloseRe(R"(\[/pkt\])");
const QRegularExpression csvOpenRe(R"(\[csv(\s+[^\]]*)?\])");
const QRegularExpression csvCloseRe(R"(\[/csv\])");
const QRegularExpression runTagRe(R"(\[run\](.*?)\[/run\])");
// CODE BLOCKS
const QRegularExpression codeBlockOpenRe(R"__(\[(cpp|py|code)(?:\s+src="([^"]+)")?\])__");
const QRegularExpression codeCloseRe(R"(\[/code\])");
const QRegularExpression cppCloseRe(R"(\[/cpp\])");
const QRegularExpression pythonCloseRe(R"(\[/py\])");
// href and image tags with attributes:
const QRegularExpression anchorRe(R"__(\[a\s+href="([^"]+)"(?:\s+name="([^"]+)")?\])__"); // Match [a href="..."] or [a href="..." name="..."]
const QRegularExpression imgRe(R"__(
\[img\s+
(?:
(?:src="([^"]+)")|
(?:alt="([^"]*)")|
(?:opis="([^"]*)")|
(?:autofit\b)
)
(?:\s+
(?:
(?:src="([^"]+)")|
(?:alt="([^"]*)")|
(?:opis="([^"]*)")|
(?:autofit\b)
)
)*
\s*\])__", QRegularExpression::ExtendedPatternSyntaxOption); // Match [img ...] with optional attributes in any order
const QRegularExpression imgAttributeSrcRe(R"__(src="([^"]+)")__");
const QRegularExpression imgAttributeAltRe(R"__(alt="([^"]*)")__");
const QRegularExpression imgAttributeDescRe(R"__(opis="([^"]*)")__");
const QRegularExpression imgAttributeAutofitRe(R"__(\bautofit\b)__");
// others
const QRegularExpression baseFormatting_boldItalicUnderlineStrikeRe(R"(\[(b|i|u|s)\])");
const QRegularExpression boldCloseRe(R"(\[/b\])");
const QRegularExpression italicCloseRe(R"(\[/i\])");
const QRegularExpression underlineCloseRe(R"(\[/u\])");
const QRegularExpression strikeOutCloseRe(R"(\[/s\])");
// const QRegularExpression wordWithPolishCharactersRe(R"(\b\p{L}+(?:[-']\p{L}+)*\b)"); - it does not catch polish
const QRegularExpression wordWithPolishCharactersRe(R"([A-Za-zĄĆĘŁŃÓŚŹŻąćęłńóśźż]{2,})");
} // namespace syntax
} // namespace stc