Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $sText = FileRead(@ScriptDir & '\парсинг.txt')
- $aArray=StringRegExp($sText, '\┃\h+\│CMD \│''([A-Za-z]+?)''(?s)(.+?)\r\n┣━+?┿━+?┿━+?┫', 3)
- ; $html = ''
- $header= _
- '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">' & @CRLF & _
- '<html>' & @CRLF & _
- '<head>' & @CRLF & _
- '<title>Справка</title>' & @CRLF & _
- '<meta content="text/html; charset=windows-1251" http-equiv="Content-Type">' & @CRLF & _
- '<link type="text/css" rel="stylesheet" href="styles.css">' & @CRLF & _
- '</head>'
- ; MsgBox(0, "Сообщение", $text)
- $html = $header
- $s=UBound($aArray)
- For $i = 0 To $s-1 Step 2
- $html0=$header
- $syntax=''
- $description=''
- $parametr=''
- $Example=''
- $Notes=''
- $name = $aArray[$i]
- $body = $aArray[$i+1]
- ; $tmp=StringRegExp($body, '\┃\h+\│FORM\│(.+?)(?=\h+\r\n)', 2)
- $tmp=StringRegExp($body, '(?s)\┃\h+\│FORM\│(.+?)(\┃\h+├─+?┼─+?┨\s+)', 2)
- If Not @error Then
- $syntax=_Del($tmp)
- EndIf
- $tmp=StringRegExp($body, '(?s)\┃(?:' & $name & ')?\h+\│Функция\│(.+?)(\┃\h+├─+?┼─+?┨\s+)', 2)
- If Not @error Then
- $description=_Del($tmp)
- EndIf
- $tmp=StringRegExp($body, '(?s)\┃(?:' & $name & ')?\h+\│PARA\│(.+?)(\┃\h+├─+?┼─+?┨\s+)', 2)
- If Not @error Then
- $parametr=_Del($tmp)
- EndIf
- $tmp=StringRegExp($body, '(?s)\┃\h+\│Пример\│(.+?)(\┃\h+├─+?┼─+?┨\s+)', 2)
- If Not @error Then
- $Example=_Del($tmp)
- EndIf
- $tmp=StringRegExp($body, '(?s)\┃\h+\│REM\h+\│(.+?)(\r\n┣━+?┿━+?┿━+?┫\s*)', 2)
- If Not @error Then
- $Notes=_Del($tmp)
- EndIf
- $html0 &= @CRLF & '<h1>' & $name & '</h1>' & @CRLF
- If $syntax Then $html0 &= @CRLF & '<h3>Синтаксис</h3>' & @CRLF & '<pre class="codeheader">' & $syntax & '</pre>'
- If $description Then $html0 &= @CRLF & '<h3>Описание</h3>' & @CRLF & '<pre class="funcdesc">' & $description & '</pre>'
- If $parametr Then $html0 &= @CRLF & '<h3>Параметры</h3>' & @CRLF & '<pre>' & $parametr & '</pre>'
- If $Example Then $html0 &= @CRLF & '<h3>Пример</h3>' & @CRLF & '<pre class="codebox">' & $Example & '</pre>'
- If $Notes Then $html0 &= @CRLF & '<h3>Примечания</h3>' & @CRLF & '<pre>' & $Notes & '</pre>'
- $html0 &= @CRLF & '<h3>Остатки</h3>' & @CRLF & '<pre>' & $body & '</pre>'
- $hFile = FileOpen(@ScriptDir & '\html\' & $name & '.htm', 2)
- FileWrite($hFile, $html0 & @CRLF & '<br /><br /><br /><br /></body></html>')
- FileClose($hFile)
- $html &= $html0
- Next
- $html &= @CRLF & '<br /><br /><br /><br /></body></html>'
- $hFile = FileOpen(@ScriptDir & '\file.htm', 2)
- FileWrite($hFile, $html)
- FileClose($hFile)
- MsgBox(0, 'Сообщение', 'Готово')
- Func _Del($tmp)
- $res = $tmp[1]
- ; $body = StringReplace($body, $tmp, '') ; удаляем найденную строку
- $body = StringReplace($body, $tmp[0], '') ; удаляем найденое
- $res=StringRegExpReplace($res, '(?:\│|\┃)\h+(?=\│)', '')
- $res = StringReplace($res, @CRLF & '|', @CRLF)
- Return $res
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement