summaryrefslogtreecommitdiff
path: root/mod/tex/context/third/rst/rst_parser.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <megas.kapaneus@gmail.com>2011-08-20 21:55:36 +0200
committerPhilipp Gesang <megas.kapaneus@gmail.com>2011-08-20 21:55:36 +0200
commitbc3bb79d16c52531387c70c24f94513b62dcfa67 (patch)
tree0beb4e1dc31026331dff2238e5af0d009c203573 /mod/tex/context/third/rst/rst_parser.lua
parent2e4451816ad9d3af5c1bdd70763b0db8f599700c (diff)
downloadcontext-rst-bc3bb79d16c52531387c70c24f94513b62dcfa67.tar.gz
optional BOM trimming
Diffstat (limited to 'mod/tex/context/third/rst/rst_parser.lua')
-rw-r--r--mod/tex/context/third/rst/rst_parser.lua11
1 files changed, 11 insertions, 0 deletions
diff --git a/mod/tex/context/third/rst/rst_parser.lua b/mod/tex/context/third/rst/rst_parser.lua
index 6aeeb7d..f5c9fbc 100644
--- a/mod/tex/context/third/rst/rst_parser.lua
+++ b/mod/tex/context/third/rst/rst_parser.lua
@@ -34,6 +34,7 @@ else
rst = require "rst_context"
end
+rst.stripBOM = false
helpers.rst_debug = false
local warn = function(str, ...)
@@ -1350,11 +1351,21 @@ local parser = P{
table_header_hline = P"=",
}
+local function strip_BOM (raw)
+ if raw:match"^\239\187\191" then
+ return raw:sub(4)
+ end
+ return raw
+end
+
local function load_file (name)
f = assert(io.open(name, "r"), "Not a file!")
if not f then return 1 end
local tmp = f:read("*all")
f:close()
+ if rst.strip_BOM then
+ return strip_BOM(tmp)
+ end
return tmp
end