<commit_before>local slash, theme_name = settings.slash, settings.theme
local pcall, settings, cursrentdir = pcall, settings, lfs.currentdir
local table, assert, error, setfenv = table, assert, error, setfenv
local currentdir = lfs.currentdir() .. slash
local base_path = base_path

setmetatable(theme, {
  __call = function(t, f, args)
    if not args then args = {} end
    if t[f] == nil then
      file = ([[%sthemes%s%s%s%s.tpl.html]]):format(currentdir, slash, theme_name, slash, f)

      local attr, err = lfs.attributes(file)
      if err then
        return ([[template '%s': %s]]):format(file, err)
      end

      if attr ~= nil and attr.mode == [[file]] then
        -- read file contents
        local fh = assert(io.open(file))
        local src = ('print [[%s]]'):format(fh:read([[*a]]))
        fh:close()

        -- load source code
        local prog, err = loadstring(src, file)<commit_msg>Adding support for lua template tags: '<?lua' and '?>'.<commit_after>local slash, theme_name = settings.slash, settings.theme
local pcall, settings, cursrentdir = pcall, settings, lfs.currentdir
local table, assert, error, setfenv = table, assert, error, setfenv
local currentdir = lfs.currentdir() .. slash
local base_path = base_path

setmetatable(theme, {
  __call = function(t, f, args)
    if not args then args = {} end
    if t[f] == nil then
      file = ([[%sthemes%s%s%s%s.tpl.html]]):format(currentdir, slash, theme_name, slash, f)

      local attr, err = lfs.attributes(file)
      if err then
        return ([[template '%s': %s]]):format(file, err)
      end

      if attr ~= nil and attr.mode == [[file]] then
        -- read file contents
        local fh = assert(io.open(file))
        local src = ('print [[%s]]'):format(fh:read([[*a]]))
        fh:close()

        -- translate lua template tag
        src = src:gsub([[(<%?lua)(.-)(%?>)]], "]]; %2print[[")

        -- load source code
        local prog, err = loadstring(src, file)
{'fraction_non_alphanumeric': 0.1559959349593496, 'fraction_numerical': 0.0005081300813008131, 'mean_word_length': 3.0597938144329895, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3696982', 'n_tokens_mistral': 661, 'n_tokens_neox': 633, 'n_words': 190}