From 9ef79b2215d894d5252961e1cb2b7050647de4fe Mon Sep 17 00:00:00 2001
From: Volpeon <git@volpeon.ink>
Date: Sun, 21 Nov 2021 21:27:26 +0100
Subject: Remove automatic titlecase algorithm

---
 scripts/metadata_filter.lua | 17 -----------------
 1 file changed, 17 deletions(-)

(limited to 'scripts')

diff --git a/scripts/metadata_filter.lua b/scripts/metadata_filter.lua
index 26d2423..d5a2909 100644
--- a/scripts/metadata_filter.lua
+++ b/scripts/metadata_filter.lua
@@ -163,22 +163,6 @@ function process_pages(global, order, pages_by_id)
     return pages_data
 end
 
-local titlecase_exceptions = pandoc.List({
-    "a", "an", "and", "as", "at", "but", "by", "en", "for", "if", "in", "nor", "of", "on", "or",
-    "per", "the", "to", "v%.?", "vs%.?", "via",
-})
-
-function titlecase(str)
-    return str:gsub("(%S)(%S*)(%s*)", function(a, b, space)
-        local word = a .. b
-        local is_exception = word:match("%u") or
-                                 titlecase_exceptions:find_if(
-                function(exception) return word:match("^" .. exception .. "$") end)
-        if is_exception then return word .. space end
-        return string.upper(a) .. b .. space
-    end)
-end
-
 function find_depth(pages)
     local depth = 0
 
@@ -291,7 +275,6 @@ function process(global, meta)
     meta.url = meta.url and pandoc.utils.stringify(meta.url)
     meta.url = resolve_url(global.site.url, global.file_out, meta.url or meta.file_out)
     meta.title = (meta.title and pandoc.utils.stringify(meta.title)) or ""
-    if meta.titlecase ~= false then meta.title = titlecase(meta.title) end
     if meta.list_order then meta.list_order = pandoc.utils.stringify(meta.list_order) end
     if meta.position then meta.position = pandoc.utils.stringify(meta.position) end
 
-- 
cgit v1.2.3-70-g09d2