4:31 6ˆl–Ãa¾”J_)â‚ Áà™S�ÿ�þBg �ºÛ1µ^þ ƒh¹ÁÀ¿4:56 7ˆl–Ãa¾”J_)â‚ ÆEq )‹Fÿ‘äÇò 8àdmù•²Œ¿Ïà ƒh¹ÂÁÀ4:54 7 ˆl–Ðz¾””¾R( J7+�¸¦-ÿ�þ[mð¬Ùe²3#$üÿÄ „_ÃÂÁ?÷ RANDOM_SEED = math.randomseed(os.time()) MATRIX_AND = {{0,0},{0,1}} MATRIX_OR = {{0,1},{1,1}} HEXES = '0123456789abcdef' local SciKGTeX = {} SciKGTeX.whole_string = "" SciKGTeX.properties_used = {} SciKGTeX.property_commands = {} SciKGTeX.mandatory_properties = { 'researchproblem', 'objective', 'method', 'result', 'conclusion' } SciKGTeX.PRODUCE_XMP_FILE = true SciKGTeX.WARNING_LEVEL = 1 local XMP = {} XMP.lines = {} XMP.namespaces = {} XMP.property_ns = {} XMP.XMP_TOP = [[]] XMP.XMP_BOTTOM = [[ ]] XMP.PACKET_END = [[]] local UUID = {} ---------------------------- utilities ------------------------------- -- performs the bitwise operation specified by truth matrix on two numbers. function BITWISE(x, y, matrix) local z = 0 local pow = 1 while x > 0 or y > 0 do z = z + (matrix[x%2+1][y%2+1] * pow) pow = pow * 2 x = math.floor(x/2) y = math.floor(y/2) end return z end function INT2HEX(x) local s,base,pow = '',16,0 local d while x > 0 do d = x % base + 1 x = math.floor(x/base) s = string.sub(HEXES, d, d)..s end if #s == 1 then s = "0" .. s end return s end function get_output_dir() if arg ~= nil then for k,v in ipairs(arg) do val, is_output_argument = v:gsub('%-%-output%-directory=(.*)','%1') if is_output_argument > 0 then return val end end return nil end return nil end function read_header_of_file(path) local fh = io.open(path, "rb") if fh then local first_line = assert(fh:read()) fh:close() return first_line else print ("No xmp metadata file found!") return nil end end function extract_uuid_from_header(header) return header:gsub('.*id=\"(.-)\".*','%1') end function generate_UUID() UUID:initialize('00:0c:29:69:41:c6') return UUID:toString() end function string:split(sep) if sep == nil then sep = "%s" end local t = {} for str in self:gmatch("([^"..sep.."]+)") do table.insert(t, str) end return t end function spaces_to_underscores(s) return s:gsub('%s+','_') end function remove_environments(s) s,c = s:gsub('\\begin%s*{.-}{.-}%s*','') s,c = s:gsub('\\begin%s*{.-}%s*','') s,c = s:gsub('\\end%s*{.-}%s*','') return s end function remove_any_latex_command(s) s, c = s:gsub('\\%w+%s*%[%d*%]%s*{(.*)}','%1') if c > 0 then return remove_latex_commands(s) end s, c = s:gsub('\\%w+%s*{(.*)}','%1') if c > 0 then return remove_latex_commands(s) end s, c = s:gsub('\\%w+%s*','') if c > 0 then return remove_latex_commands(s) end return s end function find_last_occurence(s, repls) occurences = {} for pattern, repl in pairs(repls) do i, j = s:find(pattern) if i ~= nil then table.insert(occurences, {i,j,pattern}) end end table.sort(occurences, function(l, r) return l[1]>r[1] end) if #occurences > 0 then return occurences[1] else return nil end end function exhaustively_replace_last_occurence_of_pattern(s, repls) last_occurence = find_last_occurence(s, repls) if last_occurence ~= nil then starts, ends, pattern = table.unpack(last_occurence) to_replace = s:sub(starts,ends) else return s end new_string = s:sub(0,starts-1) .. to_replace:gsub(pattern, repls[pattern], 1) .. s:sub(ends+1) return exhaustively_replace_last_occurence_of_pattern(new_string, repls) end function remove_latex_commands(s) replacements = { -- contribution with * and [] ['\\contribution%s*%*%s*%[%d*%]%s*{.-}{.*}%s*'] = '', -- contribution with * ['\\c