-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathREADME.txt
209 lines (182 loc) · 6.26 KB
/
README.txt
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
THIS FILE IS OUTDATED, DO NOT READ
🔸🔶🟧 EXAMPLE 🟧🔶🔸
═[HTML]══════════════════════════════════════
<link rel=stylesheet href=markup.css>
<script src=parse.js></script>
<script src=render.js></script>
═[JS]════════════════════════════════════════
let element = document.createElement('div')
element.classList.add('🍂')
document.body.append(element)
let text = "/test/ 123"
Markup.convert(text, element)
/* OR: */
let fragment = Markup.convert(text)
element.append(fragment)
═════════════════════════════════════════════
See ❲markup.css❳ for example styles
🔸🔶🟧 SBS CONTENTAPI EXAMPLE 🟧🔶🔸
═[HTML]═════════════════════════════════════════════
<link rel=stylesheet href=markup.css>
<script src=parse.js></script>
<script src=render.js></script>
<script src=legacy.js></script>
═[JS]═══════════════════════════════════════════════
let element = document.createElement('div')
document.body.append(element)
let message = {
text: "[i]test[/i] 123",
values: {m: 'bbcode'}
}
Markup.convert_lang(message.text, message.values.m, element)
// result: <div class='🍂'><i>test</i> 123</div>
// (set Markup.css_class to change the class name)
/* OR: */
let fragment = convert_lang(message.text, message.values.m)
element.append(fragment)
element.classList.add('whatever')
════════════════════════════════════════════════════
🔸🔶🟧 FUNCTIONS 🟧🔶🔸
‹ParentElement› = ‹Element› OR ‹DocumentFragment› OR ‹Document›
‹tree› = {type:ENUM(...), ?args:‹Object›, ?content:LIST(‹branch›)}
‹branch› = ‹tree› OR ‹String› OR `true`
‹parser› = FUNCTION(‹String›) ⤑ ‹tree›
📒❲parse.js❳
┃
┗🏭❲Markup_12y2:CLASS()❳
┃
┣📜❲.prototype❳
┃
┗📦❲new❳
┃
┗📑❲.parse:‹parser›❳
⎝parser, outputs a tree
📒❲render.js❳
┃
┗🏭❲Markup_Render:CLASS()❳
┃
┣📜❲.prototype❳
┃
┗📦❲new❳
┃
┣📑❲.render:FUNCTION(tree‹tree›, ?parent‹ParentNode›) ⤑ ‹ParentNode›❳
┃ ⎜renderer, converts the parser's tree into html.
┃ ⎜if `parent` is passed, the output is inserted into that node.
┃ ⎝otherwise, it creates and returns a new ‹DocumentFragment›
┃
┣📑❲.create:DICT ⤑ ❲FUNCTION(...) ⤑ ‹Node›❳❳
┃
┗📑❲.url_scheme:DICT ⤑ ❲FUNCTION(‹URL›) ⤑ ‹String›❳❳
📒❲legacy.js❳
┃
┗🏭❲Markup_Langs:CLASS()❳
┃
┣📜❲.prototype❳
┃
┗📦❲new❳
┃
┣📑❲.12y2:‹parser›❳
┣📑❲.text:‹parser›❳
┣📑❲.12y:‹parser›❳
┣📑❲.bbcode:‹parser›❳
┗📑❲.plaintext:‹parser›❳
📒❲helpers.js❳
┃
┣🏭❲SbsLocation:CLASS(‹String›)❳
┃ ┃
┃ ┣📜❲.prototype❳
┃ ┃ ┃
┃ ┃ ┗📑❲.toString:FUNCTION() ⤑ ‹String›❳
┃ ┃
┃ ┗📦❲new❳
┃ ┃
┃ ┣📑❲.type:‹String›❳
┃ ┃
┃ ┣📑❲?.id:‹String› OR ‹Number›❳
┃ ┃
┃ ┣📑❲.query:DICT ⤑ ‹String›❳
┃ ┃
┃ ┗📑❲?.fragment:‹String›❳
┃
┗📦❲???:CLASS() extends Markup_Render❳
┃
┣📜❲.prototype❳
┃ ┃
┃ ┣📑❲.parse:FUNCTION(‹String›, ‹String›) ⤑ ‹tree›❳
┃ ┃
┃ ┗📑❲.convert_lang:FUNCTION(‹String›, ‹String›, ?‹Element›, ?TABLE) ⤑ ‹ParentElement›❳
┃
┗📦❲new❳
┃
┣📑❲.langs:TABLE ⤑ ‹parser›❳
┃ ⎝table of parser functions for different markup languages
┃
┗📑❲.css_class:‹String›❳
⎜The css class used by `Markup.convert_lang`
⎝default value: "🍂"
📒❲legacy.js❳
┃
┣📑❲Markup.convert_lang(text‹String›, ?lang‹String›, ?parent‹Element›, ?settings) ⤑ ‹ParentNode›❳
┃ ⎜similar to Markup.convert, but supports other markup languages
┃ ⎜(see `Markup.langs`) if `lang` is invalid, 'plaintext' is used.
┃ ⎜`Markup.css_class` is added to `parent`'s class list, if passed.
┃ ⎝otherwise, creates and returns a new ‹DocumentFragment›
┃
┣📑❲Markup.css_class ‹String›❳
┃ ⎜The css class used by `Markup.convert_lang`
┃ ⎝default value: "🍂"
┃
┗📑❲Markup.langs[‹String›] ⤑ ❲‹Function›(‹String›) ⤑ ‹tree›❳❳
┃ ⎜table of parser functions for different markup languages
┃ ⎝(all output the same AST format)
┃
┣ Markup.langs['12y2']
┃ ⎝12y2 parser (Markup.parse)
┣ Markup.langs['text']
┃ ⎝new plaintext parser
┣ Markup.langs['12y']
┃ ⎝old 12y parser
┣ Markup.langs['bbcode']
┃ ⎝old bbcode parser
┗ Markup.langs['plaintext']
⎝old plaintext parser (autolinker)
🔸🔶🟧 FILES 🟧🔶🔸
📚❲./❳
┃
┣📕❲index.html❳
┃ demo page
┃
┣📔❲README.txt❳
┃ readme
┣📔❲LICENSE.txt❳
┃ license
┃
┣📒❲parse.js❳
┃ parsing (text -> tree)
┣📒❲render.js❳
┃ rendering (tree -> html (DocumentFragment))
┣📒❲legacy.js❳
┃ parsers for old sbs markup formats
┃
┣📘❲markup.css❳
┃ example styles for markup
┃
┗📚❲testing/❳
┃ tests
┃
┣📕❲index.html❳
┃ run tests
┣📕❲editor.html❳
┃ test editing tool
┃
┣📘❲style.css❳
┃ common styles for test pages
┣📒❲test.js❳
┃ test system
┗📒❲draw.js❳
test output rendering
🔸🔶🟧 CREDITS 🟧🔶🔸
🔸𝟷𝟸
🔸𝔂
🔸𝓬𝓱𝓮𝓻𝓻𝔂
🔸𝓷𝓲𝓬𝓸𝓵𝓮