annotate framework/env/parse/_pre_fold.lua @ 290:7c3aec7f1a7d
Removed timeout management (will be part of moonbridge)
 | author | 
 jbe | 
 | date | 
 Sun Mar 22 13:20:55 2015 +0100 (2015-03-22) | 
 | parents | 
 9fdfb27f8e67  | 
 | children | 
  | 
 
 | rev | 
   line source | 
| 
jbe/bsw@0
 | 
     1 function parse._pre_fold(str)
 | 
| 
jbe/bsw@0
 | 
     2   local str = str
 | 
| 
jbe/bsw@0
 | 
     3   local special_chars = charset.get_data().special_chars
 | 
| 
jbe/bsw@0
 | 
     4   local function replace(name, dst)
 | 
| 
jbe/bsw@0
 | 
     5     local src = special_chars[name]
 | 
| 
jbe/bsw@0
 | 
     6     if src then
 | 
| 
jbe/bsw@0
 | 
     7       local pattern = string.gsub(src, "[][()^$%%]", "%%%1")
 | 
| 
jbe/bsw@0
 | 
     8       str = string.gsub(str, pattern, dst)
 | 
| 
jbe/bsw@0
 | 
     9     end
 | 
| 
jbe/bsw@0
 | 
    10   end
 | 
| 
jbe/bsw@0
 | 
    11   replace("nobreak_space",  " ")
 | 
| 
jbe/bsw@0
 | 
    12   replace("minus_sign",     "-")
 | 
| 
jbe/bsw@0
 | 
    13   replace("hyphen_sign",    "-")
 | 
| 
jbe/bsw@0
 | 
    14   replace("nobreak_hyphen", "-")
 | 
| 
jbe/bsw@0
 | 
    15   replace("figure_dash",    "-")
 | 
| 
jbe/bsw@0
 | 
    16   str = string.gsub(str, "\t+", " ")
 | 
| 
jbe/bsw@0
 | 
    17   str = string.gsub(str, "^ +", "")
 | 
| 
jbe/bsw@0
 | 
    18   str = string.gsub(str, " +$", "")
 | 
| 
jbe/bsw@0
 | 
    19   str = string.gsub(str, " +", " ")
 | 
| 
jbe/bsw@0
 | 
    20   return str
 | 
| 
jbe/bsw@0
 | 
    21 end
 |