-
Notifications
You must be signed in to change notification settings - Fork 0
/
Parser.au3
460 lines (392 loc) · 18.4 KB
/
Parser.au3
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
; This file include every function strictly related to the parsing of data in .lua files
; Get the first comment block after $CarretPos
; We will also grab function declaration if possible/applicable
; The return is a Array : CarretPosition|BlockContent|Declaration|CarretPositionStart
Func ReadNextBlock($File, $CarretPos)
local $CommentBlock = "" ; This is where we'll store the comment block
local $Declaration = "" ; This is the next line after the comment block : usually the declaration statement
local $CurrentLine = ""
local $CurrentCarretPos = 0
local $IsCommentBlock = False
local $RegExResult
local $RegexPos
; Start reading from $CarretPos
FileSetPos($File, $CarretPos, $FILE_BEGIN)
; Read till we find a comment block
Do
$CurrentLine = FileReadLine($File)
If @error Then ; We probably reached the eof
Local $ReturnArray[3] = [$CurrentCarretPos, "", ""]
Return $ReturnArray
ElseIf StringInStr($CurrentLine, "---") Then
$IsCommentBlock = True
EndIf
Until $IsCommentBlock
Local $CarretPosStart = FileGetPos($File) - StringLen($CurrentLine) - 2
; Add the first line to our comment block
$RegExResult = StringRegExp($CurrentLine, "---(.*)", $STR_REGEXPARRAYMATCH)
If Not @error Then ; The first line of the comment could be empty !
$CommentBlock &= $RegExResult[0]&@CRLF
EndIf
; Read the comment block
Do
$CurrentCarretPos = FileGetPos($File)
$CurrentLine = FileReadLine($File)
If StringInStr($CurrentLine, "--") Then ; If we can't find any "--" in the line, then it's not the comment block anymore
$RegExResult = StringRegExp($CurrentLine, "--(.*)", $STR_REGEXPARRAYMATCH)
If Not @error Then; The line of the comment could be empty !
$CommentBlock &= $RegExResult[0]&@CRLF
EndIf
Else
$IsCommentBlock = False
EndIf
Until Not $IsCommentBlock
; Ok, so now this is strange. If the comment block is class', we're going to have to check the
; next comment block. If this next comment block contains a field, that is the same name as the class, then this
; new comment block contains the whole informtion for the class. This is very shitty, but it's a workaround to
; make intellisense show classes info while programing
If ParseForOneTag($CommentBlock, "@type") Then
Local $CommentBlock2 = ""
Do
$CurrentLine = FileReadLine($File)
If @error Then
Local $ReturnArray[3] = [$CurrentCarretPos, "", ""]
Return $ReturnArray
ElseIf StringInStr($CurrentLine, "---") Then
$IsCommentBlock = True
EndIf
Until $IsCommentBlock
$RegExResult = StringRegExp($CurrentLine, "---(.*)", $STR_REGEXPARRAYMATCH)
If Not @error Then
$CommentBlock2 &= $RegExResult[0]&@CRLF
EndIf
; Yep, the next comment is the description of the class, let's read on !
If StringInStr($CurrentLine, ParseForOneTag($CommentBlock, "@type")) And StringInStr($CurrentLine, "extend") Then
Do
$CurrentLine = FileReadLine($File)
If StringInStr($CurrentLine, "--") Then
$RegExResult = StringRegExp($CurrentLine, "--(.*)", $STR_REGEXPARRAYMATCH)
If Not @error Then
$CommentBlock2 &= $RegExResult[0]&@CRLF
EndIf
Else
$IsCommentBlock = False
EndIf
Until Not $IsCommentBlock
; remove the line(s) with "@field" in the comment block. They are only needed for the intellisense hack
While 1
$RegexResult = StringRegExp($CommentBlock2, "(.*)@field(.*)", $STR_REGEXPARRAYMATCH, $RegexPos)
$RegexPos = @extended
If @extended == 0 Then ExitLoop
$CommentBlock2 = StringRegExpReplace($CommentBlock2, "(.*)@field(.*)", "", 1)
WEnd
; We also don't need the first line of the first comment block anymore...
; $CommentBlock = StringRegExpReplace($CommentBlock, "(.*)", "", 1)
; append the description at the start of the comment block
$CommentBlock = $CommentBlock2&$CommentBlock
EndIf
; We also need to check if the type is a list or a map. If so, the comment block does not describe a class, but a simple list / map.
; It will have the formatting of a class, though, because it's closer closer to the actual code, even though it is highly confusing.
; But it will only have 1 field : the list or map.
If StringInStr($CommentBlock, "@list") Then
$RegExResult = StringRegExp($CommentBlock, "@list\h<(.*?)>\h(.*)", $STR_REGEXPARRAYMATCH)
if not @error Then
$CommentBlock &= "@field #table["&$RegExResult[0]&"] "&$RegExResult[1]
EndIf
EndIf
; TODO : Add support for @map the same way...
EndIf
; We'll take the next line, as it might be the declaration statement
$Declaration = $CurrentLine
; let's do some cleanup
$CommentBlock = StringRegExpReplace($CommentBlock, "(?m)^\h+", "") ;remove leading whitespaces
$CommentBlock = StringRegExpReplace($CommentBlock, "(?m)\h+$", "") ;remove trailing whitespaces
$CommentBlock = StringRegExpReplace($CommentBlock, "(?m)^[#]+", "##### ")
$CommentBlock = StringRegExpReplace($CommentBlock, "(?m)^\h+", "") ;remove leading whitespaces again now that we removed the "#"s
$CommentBlock = StringRegExpReplace($CommentBlock, "(?m)-{3,}", "") ;remove sequences of at least 3 "-" which will mess up markdown
$CommentBlock = StringRegExpReplace($CommentBlock, "(?m)={3,}", "") ; remove sequences of at least 3 "=" which will mess up markdown
Local $ReturnArray[4] = [$CurrentCarretPos, $CommentBlock, $Declaration, $CarretPosStart]
Return $ReturnArray
EndFunc
; Parses the block and returns the data for one tag
; don't use it to find the function tag !
Func ParseForOneTag($Block, $Tag)
Local $i = 1
Local $DataArray[1]
Local $RegexResult[1]
Local $RegexPos = 1
Local $Regex
; If we look for @usage, then it's a multiline data, the regex is different
If $Tag == "@usage" Then
$Regex = "(?s)@usage(.*)"
$RegexResult = StringRegExp($Block, $Regex, $STR_REGEXPARRAYMATCH, $RegexPos)
Else
$Regex = $Tag&"\h(.*)\s"
$RegexResult = StringRegExp($Block, $Regex, $STR_REGEXPARRAYMATCH, $RegexPos)
Endif
If @error Then
Return ""
Else
Return $RegexResult[0]
EndIf
EndFunc ;==>ReadOneTag
; Parses the block and returns the data for multiple tags in an array
; Don't use it for @param !
Func ParseForTags($Block, $Tag)
Local $i = 1
Local $DataArray[1]
Local $RegexResult[1]
Local $RegexPos = 1
Local $Regex = $Tag&"(?m)\h([^\s]*)(?:\h)?([^\s]*)?(?:\h)?(.*)?$"
; For each tag
While True
$RegexResult = StringRegExp($Block, $Regex, $STR_REGEXPARRAYMATCH, $RegexPos)
$RegexPos = @extended
If $RegexPos == 0 Then ; We couldn't find any tag
If Not $DataArray[0] Then
Return ""
Else
Return $DataArray
EndIf
EndIf
; Add the tag to the array.The array looks like this : type1|param1|description1|type2...
ReDim $DataArray[$i * 3]
$DataArray[($i * 3) - 3] = $RegexResult[0]
If $RegexResult[1] == "" Then
$DataArray[($i * 3) - 2] = "self" ; if the first param doesn't have a name, then it's self
Else
$DataArray[($i * 3) - 2] = $RegexResult[1]
EndIf
$DataArray[($i * 3) - 1] = $RegexResult[2]
$i += 1
WEnd
EndFunc
; Parses both the comment block and the declaration to find the function name and it's type
; Compares both of them if possible, but will always return the one in the comment block if possible
Func ParseFunctionName($CommentBlock, $Declaration)
local $RegExResult
local $FunctionNameFromDec
local $FunctionNameFromComment
local $ReturnArray[2]
; Parse for function name in both the comment block and the desclaration
$RegExResult = StringRegExp($CommentBlock, "\@function\h(?:(\[.*\]\h))?(.*)", $STR_REGEXPARRAYMATCH)
If Not @error Then
$FunctionNameFromComment = $RegExResult[1]
EndIf
$RegExResult = StringRegExp($Declaration, "function\h(?:.*\:)?(.*)\(.*\)", $STR_REGEXPARRAYMATCH)
If Not @error Then
$FunctionNameFromDec = $RegExResult[0]
EndIf
; compare them to each other
If $FunctionNameFromComment Then
If $FunctionNameFromDec <> $FunctionNameFromComment Then
FileWrite($Log,"CAUTION : The commented function doesn't match its declaration : "&$FunctionNameFromComment& " -> "&$Declaration&@CRLF)
EndIf
$ReturnArray[0] = $FunctionNameFromComment
ElseIf $FunctionNameFromDec Then
;FileWrite($Log, "CAUTION: No data matching @function found in block, inferring the function name from its declaration : "& $FunctionNameFromDec & @CRLF)
$ReturnArray[0] = $FunctionNameFromDec
Else
$ReturnArray[0] = ""
$ReturnArray[1] = ""
return $ReturnArray
EndIf
;parses for function type in both the comment block and the desclaration
local $TypeFromComment
local $TypeFromDec
$RegExResult = StringRegExp($Declaration, "function\h(.*):", $STR_REGEXPARRAYMATCH)
If Not @error Then
$TypeFromDec = $RegExResult[0]
EndIf
$RegExResult = StringRegExp($CommentBlock, "function\h\[parent=#(.*)\]", $STR_REGEXPARRAYMATCH)
If Not @error Then
$TypeFromComment = $RegExResult[0]
EndIf
; compare them to each other
If $TypeFromComment Then
If $TypeFromDec <> $TypeFromComment Then
FileWrite($Log,"CAUTION : The commented function type doesn't match its declaration : "&$TypeFromComment& " -> "&$Declaration&@CRLF)
EndIf
$ReturnArray[1] = $TypeFromComment
ElseIf $TypeFromDec Then
;FileWrite($Log, "CAUTION: No function type found in block, inferring the function type from its declaration : "& $TypeFromDec & @CRLF)
$ReturnArray[1] = $TypeFromDec
Else
$ReturnArray[0] = ""
$ReturnArray[1] = ""
return $ReturnArray
EndIf
Return $ReturnArray
EndFunc
; Specifically designed to parse for @param tags
; will verify the comment by matching with the declaration (theoretically, I'm pretty sure it's bugged)
Func ParseParams($CommentBlock, $Declaration)
Local $ParamsFromComment = ParseForTags($CommentBlock, "@param")
Local $RegExResult
Local $RegexPos = StringInStr($Declaration, "(")
Local $ParamsFromDec[0]
Local $NbParam = 0
If StringInStr($Declaration, ":") Then
$NbParam = 1
ReDim $ParamsFromDec[1]
$ParamsFromDec[0] = "self"
EndIf
; extract params from function decaration
While True
$RegExResult = StringRegExp($Declaration, "([^,\(\)\h]+)", $STR_REGEXPARRAYMATCH, $RegexPos)
$RegexPos = @extended
If @extended == 0 Then ExitLoop
$NbParam += 1
Redim $ParamsFromDec[$NbParam]
$ParamsFromDec[$NbParam-1] = $RegExResult[0]
WEnd
; compare these parameters with those found in the comment block
If UBound($ParamsFromComment) <> UBound($ParamsFromDec)*3 Then
FileWrite($Log, "CAUTION: The number of parameters don't match between the comment block and declaration "& @CRLF)
Else
For $i=0 To $NbParam-1
If $ParamsFromDec[$i] <> $ParamsFromComment[($i*3)+1] Then
FileWrite($Log, "CAUTION: Parameters missmatch between the comment block and declaration "& @CRLF)
FileWrite($Log, $ParamsFromComment[($i*3)+1]& " -> " & $ParamsFromDec[$i]&@CRLF)
ExitLoop
EndIf
Next
EndIf
Return $ParamsFromComment
EndFunc
; This does 3 things :
; - Replace the hyperlinks with new ones
; - change the stuff starting with # (#nil -> <u>Nil</u>)
; - Replace pictures paths
Func ReplaceHyperlinks($TempFile)
Local $StringFile = ""
Local $RegexResult
Local $RegexPos = 1
Local $NewURL = ""
Local $i = 0
FileSetPos($TempFile, 0, $FILE_BEGIN)
$StringFile = FileRead($TempFile)
; Replace HyperLinks Using Regexs
; ---------------------------------------------------------
While 1 ; @{File.Module}
$RegexResult = StringRegExp($StringFile, "\@{([A-Z][^\.#}]+)\.([^\.#}]+)}", $STR_REGEXPARRAYMATCH, $RegexPos) ;
$RegexPos = @extended
If @extended == 0 Then ExitLoop
$NewURL = "[" & $RegexResult[1] & "](#" & StringLower($RegexResult[1]) & "-module-)"
;FileWrite($Log, "Module : " & $RegexPos & " : " & _ArrayToString($RegexResult) & " -> " & $NewURL & @CRLF)
$StringFile = StringRegExpReplace($StringFile, "\@{([A-Z][^\.#}]+)\.([^\.#}]+)}", $NewURL, 1)
WEnd
While 1 ; @{Module}
$RegexResult = StringRegExp($StringFile, "\@{([A-Z][^\.#}]+)}", $STR_REGEXPARRAYMATCH, $RegexPos)
$RegexPos = @extended
If @extended == 0 Then ExitLoop
$NewURL = "[" & $RegexResult[0] & "](#" & StringLower($RegexResult[0]) & "-module-)"
;FileWrite($Log, "Module : " & $RegexPos & " : " & _ArrayToString($RegexResult) & " -> " & $NewURL & @CRLF)
$StringFile = StringRegExpReplace($StringFile, "\@{([A-Z][^\.#}]+)}", $NewURL, 1)
WEnd
While 1 ; @{File.Module#TYPE}
$RegexResult = StringRegExp($StringFile, "\@{([A-Z][^\.#}]+)\.([A-Z][^\.#}]+)#([A-Z,_]+)}", $STR_REGEXPARRAYMATCH, $RegexPos)
$RegexPos = @extended
If @extended == 0 Then ExitLoop
$NewURL = "[" & $RegexResult[2] & "](#" & StringLower($RegexResult[2]) & "-class-)"
;FileWrite($Log, "Class : " & $RegexPos & " : " & _ArrayToString($RegexResult) & " -> " & $NewURL & @CRLF)
$StringFile = StringRegExpReplace($StringFile, "\@{([A-Z][^\.#}]+)\.([A-Z][^\.#}]+)#([A-Z,_]+)}", $NewURL, 1)
WEnd
While 1 ; @{Module#TYPE}
$RegexResult = StringRegExp($StringFile, "\@{([A-Z][^\.#}]+)#([A-Z,_]+)}", $STR_REGEXPARRAYMATCH, $RegexPos)
$RegexPos = @extended
If @extended == 0 Then ExitLoop
$NewURL = "[" & $RegexResult[1] & "](#" & StringLower($RegexResult[1]) & "-class-)"
;FileWrite($Log, "Class : " & $RegexPos & " : " & _ArrayToString($RegexResult) & " -> " & $NewURL & @CRLF)
$StringFile = StringRegExpReplace($StringFile, "\@{([A-Z][^\.#}]+)#([A-Z,_]+)}", $NewURL, 1)
WEnd
While 1 ; @{#TYPE}
$RegexResult = StringRegExp($StringFile, "\@{#([A-Z,_]+)}", $STR_REGEXPARRAYMATCH, $RegexPos)
$RegexPos = @extended
If @extended == 0 Then ExitLoop
$NewURL = "[" & $RegexResult[0] & "](#" & StringLower($RegexResult[0]) & "-class-)"
;FileWrite($Log, "Class : " & $RegexPos & " : " & _ArrayToString($RegexResult) & " -> " & $NewURL & @CRLF)
$StringFile = StringRegExpReplace($StringFile, "\@{#([A-Z,_]+)}", $NewURL, 1)
WEnd
While 1 ; #TYPE&@CR
$RegexResult = StringRegExp($StringFile, "\h#([A-Z,_]+)\s", $STR_REGEXPARRAYMATCH, $RegexPos)
$RegexPos = @extended
If @extended == 0 Then ExitLoop
$NewURL = " [" & $RegexResult[0] & "](#" & StringLower($RegexResult[0]) & "-class-)"&@CRLF
;FileWrite($Log, "Class : " & $RegexPos & " : " & _ArrayToString($RegexResult) & " -> " & $NewURL & @CRLF)
$StringFile = StringRegExpReplace($StringFile, "\h#([A-Z,_]+)\s", $NewURL, 1)
WEnd
While 1 ; @{File.Module#TYPE.Function}(), catches the parenthesis
$RegexResult = StringRegExp($StringFile, "\@{([A-Z][^#}\.]+)\.([A-Z][^#}\.]+)#([A-Z,_]+)\.([^#\.]+)}[\(]?[\)]?", $STR_REGEXPARRAYMATCH, $RegexPos)
$RegexPos = @extended
If @extended == 0 Then ExitLoop
$NewURL = FindInFunctionList($RegexResult[2] & "-" & $RegexResult[3]&"-")
;FileWrite($Log, "Class : " & $RegexPos & " : " & _ArrayToString($RegexResult) & " -> " & $NewURL & @CRLF)
$StringFile = StringRegExpReplace($StringFile, "\@{([A-Z][^#}\.]+)\.([A-Z][^#}\.]+)#([A-Z,_]+)\.([^#\.]+)}[\(]?[\)]?", $NewURL, 1)
WEnd
While 1 ; @{Module#TYPE.Function}(), catches the parenthesis
$RegexResult = StringRegExp($StringFile, "\@{([A-Z][^#}\.]+)#([A-Z,_]+)\.([^#}\.]+)}[\(]?[\)]?", $STR_REGEXPARRAYMATCH, $RegexPos)
$RegexPos = @extended
If @extended == 0 Then ExitLoop
$NewURL = FindInFunctionList($RegexResult[1] & "-" & $RegexResult[2]&"-")
;FileWrite($Log, "Class : " & $RegexPos & " : " & _ArrayToString($RegexResult) & " -> " & $NewURL & @CRLF)
$StringFile = StringRegExpReplace($StringFile, "\@{([A-Z][^#}\.]+)#([A-Z,_]+)\.([^#}\.]+)}[\(]?[\)]?", $NewURL, 1)
WEnd
While 1 ; @{#TYPE.Function}(), catches the parenthesis
$RegexResult = StringRegExp($StringFile, "\@{#([A-Z,_]+)\.([^#}\.]+)}[\(]?[\)]?", $STR_REGEXPARRAYMATCH, $RegexPos)
$RegexPos = @extended
If @extended == 0 Then ExitLoop
$NewURL = FindInFunctionList($RegexResult[0] & "-" & $RegexResult[1]&"-")
;FileWrite($Log, "Class : " & $RegexPos & " : " & _ArrayToString($RegexResult) & " -> " & $NewURL & @CRLF)
$StringFile = StringRegExpReplace($StringFile, "\@{#([A-Z,_]+)\.([^#}\.]+)}[\(]?[\)]?", $NewURL, 1)
WEnd
While 1 ; Module#TYPE
$RegexResult = StringRegExp($StringFile, "\h(\w+[^\h\_])#(.*?)\h", $STR_REGEXPARRAYMATCH, $RegexPos)
$RegexPos = @extended
If @extended == 0 Then ExitLoop
$NewURL = " [" & $RegexResult[1] & "](#" & StringLower($RegexResult[1]) & "-class-) "
;FileWrite($Log, "Class : " & $RegexPos & " : " & _ArrayToString($RegexResult) & " -> " & $NewURL & @CRLF)
$StringFile = StringRegExpReplace($StringFile, "\h(\w+[^\h\_])#(.*?)\h", $NewURL, 1)
WEnd
While 1 ; File.Module#TYPE
$RegexResult = StringRegExp($StringFile, "\h(\w+)\.(\w+)#(.*?)\h", $STR_REGEXPARRAYMATCH, $RegexPos)
$RegexPos = @extended
If @extended == 0 Then ExitLoop
$NewURL = " [" & $RegexResult[2] & "](#" & StringLower($RegexResult[2]) & "-class-) "
;FileWrite($Log, "Class : " & $RegexPos & " : " & _ArrayToString($RegexResult) & " -> " & $NewURL & @CRLF)
$StringFile = StringRegExpReplace($StringFile, "\h(\w+)\.(\w+)#(.*?)\h", $NewURL, 1)
WEnd
While 1 ; #TYPE.type (nested type... really annoying and confusing lua stuff)
$RegexResult = StringRegExp($StringFile, "\h#([A-Z,_]+)\.(\w+)\h", $STR_REGEXPARRAYMATCH, $RegexPos)
$RegexPos = @extended
If @extended == 0 Then ExitLoop
$NewURL = " [" & $RegexResult[1] & "](#" &StringLower($RegexResult[0])& "-"& StringLower($RegexResult[1]) & "-class-)"
;FileWrite($Log, "Class : " & $RegexPos & " : " & _ArrayToString($RegexResult) & " -> " & $NewURL & @CRLF)
$StringFile = StringRegExpReplace($StringFile, "\h#([A-Z,_]+)\.(\w+)\h", $NewURL, 1)
WEnd
; Clean stuff with #
; ---------------------------------------------------------
$StringFile = StringReplace($StringFile, "#nil", "<u>Nil</u>")
$StringFile = StringReplace($StringFile, "#number", "<u>Number</u>")
$StringFile = StringReplace($StringFile, "#boolean", "<u>Boolean</u>")
$StringFile = StringReplace($StringFile, "#string", "<u>String</u>")
$StringFile = StringReplace($StringFile, "#table", "<u>List[]</u>")
$StringFile = StringReplace($StringFile, "#function", "<u>Function()</u>")
; And replace the pictures Path if any
; ---------------------------------------------------------
While 1
$RegexResult = StringRegExp($StringFile, "!\[(.*)\]\(.*\\(.*)\\(.*)\)", $STR_REGEXPARRAYMATCH, $RegexPos)
$RegexPos = @extended
If @extended == 0 Then ExitLoop
$NewPic = "![" & $RegexResult[0] & "](/includes/Pictures/" & $RegexResult[1] & "/"& $RegexResult[2]&")"
$StringFile = StringRegExpReplace($StringFile, "!\[(.*)\]\(.*\\(.*)\\(.*)\)", $NewPic, 1)
WEnd
While 1
$RegexResult = StringRegExp($StringFile, "(?m)^(\d(?:(\.\d))*\)(.*))$", $STR_REGEXPARRAYMATCH, $RegexPos)
$RegexPos = @extended
If @extended == 0 Then ExitLoop
;$StringFile = StringRegExpReplace($StringFile, "(?m)^(\d(?:(\.\d))*\)(.*))$", "<h4>"&$RegExResult[0]&"</h4>", 1)
$StringFile = StringRegExpReplace($StringFile, "(?m)^(\d(?:(\.\d))*\)(.*))$", "##### "&$RegExResult[0], 1)
WEnd
Return $StringFile
EndFunc