Advertisement
AZJIO

Processing

Aug 24th, 2012
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 7.95 KB | None | 0 0
  1. $sExampleData = FileRead($sFileExample)
  2. ; --- обработка примеров ---
  3. $sExampleData = StringRegExpReplace($sExampleData, '(<span class="S(\d)">)((?:&nbsp;|[ ])+)(</span>)', '\3') ; удаляем теги пробелов, которые не могут быть цветными
  4. ; удаление последовательных одинаковых тегов, кроме keywords
  5. Do
  6.     $sExampleData=StringRegExpReplace($sExampleData, '(<span class="S([0-389])">[^<]*?)</span>([\s]*)<span class="S\2">', '\1\3')
  7. Until @Extended=0
  8. Switch $sType
  9.     Case "keywords"
  10.         $sExampleData=StringRegExpReplace($sExampleData, '<span class="S4">([\w\d]+?)</span>', '<a class="le" href="../functions/\1.htm"><span class="S4">\1</span></a>')
  11.         $sExampleData=StringReplace($sExampleData, 'href="../functions/Opt.htm">', 'href="../functions/AutoItSetOption.htm">')
  12.         ; операторы
  13.         $sExampleData=StringRegExpReplace($sExampleData, '(?i)<span class="S8">((?:[+^*/=&-]|&gt;|&lt;)+)</span>', '<a class="le" href="../intro/lang_operators.htm"><span class="S8">\1</span></a>')
  14.         $sExampleData=StringRegExpReplace($sExampleData, '(?i)<span class="S5">(Not|And|Or)</span>', '<a class="le" href="../intro/lang_operators.htm"><span class="S5">\1</span></a>')
  15.         ; замена ключевые слова
  16.         $sExampleData=StringRegExpReplace($sExampleData, '(?i)<span class="S5">(ContinueCase|ContinueLoop|Default|Dim|Do|Enum|Exit|ExitLoop|For|Func|If|ReDim|Select|Static|Switch|While|With)</span>', '<a class="le" href="\1.htm"><span class="S5">\1</span></a>')
  17.         $sExampleData=StringRegExpReplace($sExampleData, '(?i)<span class="S5">(Else|Then|ElseIf|EndIf)</span>', '<a class="le" href="IfElseEndIf.htm"><span class="S5">\1</span></a>')
  18.         $sExampleData=StringRegExpReplace($sExampleData, '(?i)<span class="S5">(Next|To|Step)</span>', '<a class="le" href="For.htm"><span class="S5">\1</span></a>')
  19.         $sExampleData=StringRegExpReplace($sExampleData, '(?i)<span class="S5">(Case|EndSwitch)</span>', '<a class="le" href="Switch.htm"><span class="S5">\1</span></a>')
  20.         $sExampleData=StringRegExpReplace($sExampleData, '(?i)<span class="S5">(Global|Local|Const)</span>', '<a class="le" href="Dim.htm"><span class="S5">\1</span></a>')
  21.         $sExampleData=StringRegExpReplace($sExampleData, '(?i)<span class="S5">(EndFunc|ByRef|Return)</span>', '<a class="le" href="Func.htm"><span class="S5">\1</span></a>')
  22.         $sExampleData=StringRegExpReplace($sExampleData, '(?i)<span class="S5">(True|False)</span>', '<a class="le" href="Booleans.htm"><span class="S5">\1</span></a>')
  23.         $sExampleData=StringReplace($sExampleData, '<span class="S5">Until</span>', '<a class="le" href="Do.htm"><span class="S5">Until</span></a>')
  24.         $sExampleData=StringReplace($sExampleData, '<span class="S5">WEnd</span>', '<a class="le" href="While.htm"><span class="S5">WEnd</span></a>')
  25.         $sExampleData=StringReplace($sExampleData, '<span class="S5">EndSelect</span>', '<a class="le" href="Select.htm"><span class="S5">EndSelect</span></a>')
  26.         $sExampleData=StringReplace($sExampleData, '<span class="S5">In</span>', '<a class="le" href="ForInNext.htm"><span class="S5">In</span></a>')
  27.         $sExampleData=StringReplace($sExampleData, '<span class="S5">EndWith</span>', '<a class="le" href="With.htm"><span class="S5">EndWith</span></a>')
  28.        
  29.         $sExampleData=StringReplace($sExampleData, '<span class="S11">#OnAutoItStartRegister</span>', '<a class="le" href="OnAutoItStartRegister.htm"><span class="S11">#OnAutoItStartRegister</span></a>')
  30.         $sExampleData=StringReplace($sExampleData, '<span class="S11">#include</span>', '<a class="le" href="include.htm"><span class="S11">#include</span></a>')
  31.         $sExampleData=StringReplace($sExampleData, '<span class="S11">#include-once</span>', '<a class="le" href="include-once.htm"><span class="S11">#include-once</span></a>')
  32.         $sExampleData=StringReplace($sExampleData, '<span class="S11">#RequireAdmin</span>', '<a class="le" href="RequireAdmin.htm"><span class="S11">#RequireAdmin</span></a>')
  33.         $sExampleData=StringReplace($sExampleData, '<span class="S11">#NoTrayIcon</span>', '<a class="le" href="NoTrayIcon.htm"><span class="S11">#NoTrayIcon</span></a>')
  34.     Case "functions"
  35.         $sExampleData=StringRegExpReplace($sExampleData, '<span class="S4">([\w\d]+?)</span>', '<a class="le" href="\1.htm"><span class="S4">\1</span></a>')
  36.         $sExampleData=StringReplace($sExampleData, 'href="Opt.htm">', 'href="AutoItSetOption.htm">')
  37.         $sExampleData=StringRegExpReplace($sExampleData, '(?i)<span class="S8">((?:[+^*/=&-]|&gt;|&lt;)+)</span>', '<a class="le" href="../intro/lang_operators.htm"><span class="S8">\1</span></a>')
  38.         $sExampleData=StringRegExpReplace($sExampleData, '(?i)<span class="S5">(Not|And|Or)</span>', '<a class="le" href="../intro/lang_operators.htm"><span class="S5">\1</span></a>')
  39.         ; замена ключевые слова
  40.         $sExampleData=StringRegExpReplace($sExampleData, '(?i)<span class="S5">(ContinueCase|ContinueLoop|Default|Dim|Do|Enum|Exit|ExitLoop|For|Func|If|ReDim|Select|Static|Switch|While|With)</span>', '<a class="le" href="../keywords/\1.htm"><span class="S5">\1</span></a>')
  41.         $sExampleData=StringRegExpReplace($sExampleData, '(?i)<span class="S5">(Else|Then|ElseIf|EndIf)</span>', '<a class="le" href="../keywords/IfElseEndIf.htm"><span class="S5">\1</span></a>')
  42.         $sExampleData=StringRegExpReplace($sExampleData, '(?i)<span class="S5">(Next|To|Step)</span>', '<a class="le" href="../keywords/For.htm"><span class="S5">\1</span></a>')
  43.         $sExampleData=StringRegExpReplace($sExampleData, '(?i)<span class="S5">(Case|EndSwitch)</span>', '<a class="le" href="../keywords/Switch.htm"><span class="S5">\1</span></a>')
  44.         $sExampleData=StringRegExpReplace($sExampleData, '(?i)<span class="S5">(Global|Local|Const)</span>', '<a class="le" href="../keywords/Dim.htm"><span class="S5">\1</span></a>')
  45.         $sExampleData=StringRegExpReplace($sExampleData, '(?i)<span class="S5">(EndFunc|ByRef|Return)</span>', '<a class="le" href="../keywords/Func.htm"><span class="S5">\1</span></a>')
  46.         $sExampleData=StringRegExpReplace($sExampleData, '(?i)<span class="S5">(True|False)</span>', '<a class="le" href="../keywords/Booleans.htm"><span class="S5">\1</span></a>')
  47.         $sExampleData=StringReplace($sExampleData, '<span class="S5">Until</span>', '<a class="le" href="../keywords/Do.htm"><span class="S5">Until</span></a>')
  48.         $sExampleData=StringReplace($sExampleData, '<span class="S5">WEnd</span>', '<a class="le" href="../keywords/While.htm"><span class="S5">WEnd</span></a>')
  49.         $sExampleData=StringReplace($sExampleData, '<span class="S5">EndSelect</span>', '<a class="le" href="../keywords/Select.htm"><span class="S5">EndSelect</span></a>')
  50.         $sExampleData=StringReplace($sExampleData, '<span class="S5">In</span>', '<a class="le" href="../keywords/ForInNext.htm"><span class="S5">In</span></a>')
  51.         $sExampleData=StringReplace($sExampleData, '<span class="S5">EndWith</span>', '<a class="le" href="../keywords/With.htm"><span class="S5">EndWith</span></a>')
  52.        
  53.         $sExampleData=StringReplace($sExampleData, '<span class="S11">#OnAutoItStartRegister</span>', '<a class="le" href="../keywords/OnAutoItStartRegister.htm"><span class="S11">#OnAutoItStartRegister</span></a>')
  54.         $sExampleData=StringReplace($sExampleData, '<span class="S11">#include</span>', '<a class="le" href="../keywords/include.htm"><span class="S11">#include</span></a>')
  55.         $sExampleData=StringReplace($sExampleData, '<span class="S11">#include-once</span>', '<a class="le" href="../keywords/include-once.htm"><span class="S11">#include-once</span></a>')
  56.         $sExampleData=StringReplace($sExampleData, '<span class="S11">#RequireAdmin</span>', '<a class="le" href="../keywords/RequireAdmin.htm"><span class="S11">#RequireAdmin</span></a>')
  57.         $sExampleData=StringReplace($sExampleData, '<span class="S11">#NoTrayIcon</span>', '<a class="le" href="../keywords/NoTrayIcon.htm"><span class="S11">#NoTrayIcon</span></a>')
  58.     Case "libfunctions"
  59.         $sExampleData=StringRegExpReplace($sExampleData, '<span class="S15">([\w\d]+?)</span>', '<a class="le" href="\1.htm"><span class="S15">\1</span></a>')
  60. EndSwitch
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement