-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy patheksitext-2024.peggy
72 lines (40 loc) · 1.49 KB
/
eksitext-2024.peggy
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// ekşi sözlük entry markup syntax
// ssg - 2024-08-02
// run .\generate-parser.cmd to build the parser
eksi_text = (directive / $plain_text)+
directive = bkz
/ gbkz
/ abkz
/ named_url
/ url
/ paragraph_break
/ line_break
gbkz = "`" SPACE* query:$query SPACE* "`" { return { type: "gbkz", query: query } }
named_url = "[" url:url SPACE+ title:plain_text "]"
url = url:$(scheme host port? path? url_query?) { return { type: "url", url } }
bkz = "(bkz" [\':;.] SPACE* query:$query ")" { return { type: "bkz", query: query } }
abkz = "`" SPACE* visible:query? ":" hidden:query SPACE* "`" { return { type: "abkz", text: visible, query: hidden } }
paragraph_break = line_break|2..| { return { type: "paragraph_break" } }
line_break = NEWLINE { return { type: "line_break" } }
query = $(entry_query / nick_query / title:title ("/" (nick_query / entry_query / seq))?)
nick_query = "@" nick:$nick
entry_query = "#" entry_id:$entry_id
nick = NICK_CHAR+ (SPACE NICK_CHAR+)*
title_component = TITLE_CHAR+ (SPACE TITLE_CHAR+)*
title = title:$title_component (SPACE "(" kind:$title_component ")")?
entry_id = NUMBER
seq = NUMBER
NUMBER = DIGIT+
SPACE = ' '
DIGIT = [0-9]
ASCII_LETTER = [a-z]
TURKISH_LETTER = [şğüöçıŞĞÜÖÇİ]
TITLE_CHAR = ASCII_LETTER / TURKISH_LETTER / DIGIT
NICK_CHAR = ASCII_LETTER / DIGIT
NEWLINE = [\n]
scheme = "http" "s"? "://"
host = [a-z-0-9.]+
port = ":[0-9]{1,5}"
path = "/" [^?/]* path*
url_query = "?" [^\x0020\]]+
plain_text = (!directive .)+