<commit_before>
-- collect all questions
questions = {}


-- generate table of all question headers
function collectQuestionHeaders(el)
    local p = tonumber(el.attributes["punkte"]) or 0
    local c = el.content

    -- collect only questions with points ...
    if p > 0 then
        table.insert(c, pandoc.Space())
        table.insert(c, pandoc.Str("(" .. p .. "P)"))
        table.insert(questions, pandoc.MetaInlines(c))
    end
end


-- set question metadata (if requested)
function setQuestionMetadata(meta)
    meta["questions"] = pandoc.MetaList(questions)

    return meta
end


return { { Header = collectQuestionHeaders }, { Meta = setQuestionMetadata } }
<commit_msg>refactor questions filter to improve readability<commit_after>
-- collect all questions
local questions = {}


-- generate table of all question headers
function collectQuestionHeaders(el)
    local p = tonumber(el.attributes["punkte"]) or 0
    local c = el.content

    -- collect only questions with points ...
    if p > 0 then
        c:insert(pandoc.Space())
        c:insert(pandoc.Str("(" .. p .. "P)"))
        questions[#questions + 1] = pandoc.MetaInlines(c)
    end
end


-- set question metadata (if requested)
function setQuestionMetadata(meta)
    meta["questions"] = pandoc.MetaList(questions)

    return meta
end


return {
    { Header = collectQuestionHeaders },    -- First run: collect all questions
    { Meta = setQuestionMetadata }          -- Second run: add questions to metadata
}
{'fraction_non_alphanumeric': 0.11342281879194631, 'fraction_numerical': 0.003355704697986577, 'mean_word_length': 3.084931506849315, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5272123', 'n_tokens_mistral': 434, 'n_tokens_neox': 409, 'n_words': 130}