Modul:Interlinear

Version vom 17. September 2024, 16:21 Uhr von Niko Roether (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „local M = {} local abbr = mw.loadData("Module:Interlinear/abbreviations") local function parse_words(text) local words = {} local index = 0 while index <= #text do if mw.ustring.match(text, "^{", index) then index = index + 1 end_delim = mw.ustring.find(text, "}", index) if end_delim == nil then end_delim = #text + 1 end table.insert(words, mw.ustring.sub(text, index, end_delim - 1)) index = end_delim + 1 else local word_match =…“)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)

Die Dokumentation für dieses Modul kann unter Modul:Interlinear/Doku erstellt werden

local M = {}

local abbr = mw.loadData("Module:Interlinear/abbreviations")

local function parse_words(text)
	local words = {}
	local index = 0
	while index <= #text do
		if mw.ustring.match(text, "^{", index) then
			index = index + 1
			end_delim = mw.ustring.find(text, "}", index)
			if end_delim == nil then end_delim = #text + 1 end
			table.insert(words, mw.ustring.sub(text, index, end_delim - 1))
			index = end_delim + 1
		else
			local word_match = mw.ustring.match(text, "^%S+", index)
			if word_match ~= nil then
				table.insert(words, word_match)
				index =	index + #word_match + 1
			else
				local ws_match = mw.ustring.match(text, "^%s*", index)
				index = index + #ws_match
			end
		end
	end
	return words
end

M.parse_words = parse_words

return M