Module talk:Lang-zh: Difference between revisions

Content deleted Content added
Line 165:
::::I think it's fine to strip all quote marks, in any quantity. That was the original intent of the code, and I don't see any complaints on this page. Adding bold to text is probably against [[WP:MOS]], and adding italics should be done with a parameter. People can use {{tag|b}} and {{tag|i}} tags if they insist on them. – [[User:Jonesey95|Jonesey95]] ([[User talk:Jonesey95|talk]]) 15:51, 24 September 2024 (UTC)
:::::Okay. I had taken your comment about fixing the Zhuzilin station article to mean that keeping the bold markup was intended, but I can see why it could be discouraged. I've also just found [[Template:Lang-zh/testcases]] (I had only looked under Module:Lang-zh before), and I don't see any testcases for stripping markup. So, if stripping markup is the desired functionality, the .- version above would work. I think it would make sense to document this, since there are three different kinds of thing being stripped: whitespace, markup, and quotes (double quotes aren't markup). It could be documented either on [[Template:Lang-zh/doc]] or directly as a code comment next to the line we're discussing, e.g. "remove trailing and leading spaces, quotes, and bold/italic markup". [[User:Freelance Intellectual|Freelance Intellectual]] ([[User talk:Freelance Intellectual|talk]]) 20:39, 24 September 2024 (UTC)
:::::Currently, this stripping only applies to literal glosses and not translations, but they should reasonably be treated the same. So, fixing the pattern, expanding the comments, and applying the same to the translation, I suggest changing lines 236-247 to the following:<syntaxhighlight> elseif (part == "l") then
local terms = ""
-- put individual, potentially comma-separated glosses in single quotes
-- (first strip leading and trailing spaces and quotes, including bold/italic markup)
for term in val:gmatch("[^;,]+") do
term = string.gsub(term, "^([ \"']*)(.-)([ \"']*)$", "%2")
terms = terms .. "&apos;" .. term .. "&apos;, "
end
val = string.sub(terms, 1, -3)
elseif (part == "tr") then
-- put translations in double quotes
-- (first strip leading and trailing spaces and quotes, including bold/italic markup)
val = string.gsub(val, "^([ \"']*)(.-)([ \"']*)$", "%2")
val = "&quot;" .. val .. "&quot;"
end</syntaxhighlight> [[User:Freelance Intellectual|Freelance Intellectual]] ([[User talk:Freelance Intellectual|talk]]) 09:31, 25 September 2024 (UTC)