webmcp

view framework/env/parse/_pre_fold.lua @ 31:1cd9e69b85cb

add execute.load_chunk(args)

load_chunk loads the content of a lua file and returns the code.
It can construct the path name easily so you can put helper code in
seperate files for DRYness.
author Daniel Poelzleithner <poelzi@poelzi.org>
date Tue Oct 05 02:34:04 2010 +0200 (2010-10-05)
parents 9fdfb27f8e67
children
line source
1 function parse._pre_fold(str)
2 local str = str
3 local special_chars = charset.get_data().special_chars
4 local function replace(name, dst)
5 local src = special_chars[name]
6 if src then
7 local pattern = string.gsub(src, "[][()^$%%]", "%%%1")
8 str = string.gsub(str, pattern, dst)
9 end
10 end
11 replace("nobreak_space", " ")
12 replace("minus_sign", "-")
13 replace("hyphen_sign", "-")
14 replace("nobreak_hyphen", "-")
15 replace("figure_dash", "-")
16 str = string.gsub(str, "\t+", " ")
17 str = string.gsub(str, "^ +", "")
18 str = string.gsub(str, " +$", "")
19 str = string.gsub(str, " +", " ")
20 return str
21 end

Impressum / About Us