Module talk:TagQS

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

require('strict')[edit]

{{Edit protected}} As per the new lua feature mentioned at m:Tech/News/2022/42, could require('Module:No globals') be replaced with require('strict') -- WOSlinker (talk) 17:21, 25 October 2022 (UTC)[reply]

✓ Done Jonesey95 (talk) 16:10, 26 October 2022 (UTC)[reply]

tags are NOT invisible[edit]

It is requested that an edit or modification be made to this protected page.
Administrators/template editors: Please apply <nowiki> or {{Tl}} to the tag after the request is fulfilled.

Verdy p

Current they are generated using "div" elements to contain them. Even if they have a CSS style "display:none" (meaning that they won't be rendered in HTML, they are still visible to MediaWiki, that breaks existing paragraphs (or list items and in numbered or bulleted lists).

  1. Demo: "This is in English
label QS:Lfr,"Ceci est en français"
label QS:Len,"This is in English"

". (Notice that there's NO line break in that list item starting at Demo, up to the end of this comment and there should be none, the result should be fully inline within the 1st list item; if you see theclosing double quote at start of this paragraph, this is not a typo, but a defect caused by QStags, that broke the quotation in the 1st list item; "bdi" is the only HTML element supporting that transparency in Mediawiki, not "span" elements which don't allow "mixed" contents for the value; and "bdi" is anyway shorter than "span": we want QStags to be as compact as possible in the generated HTML).

  1. This should be the 2nd item of the same uninterrupted list.

Please change "div" elements into "bdi" ; and DON'T insert any space or newline before or after opening/closing tags (to avoid their propagation/move outside the element by the "HTML Tidy" step of the Mediawiki conversion to HTML (there may be spaces, but only in the middle of the embedded text.

In summary the generated tags must be like:

<bdi style="display:none">label QS:Llang,"some value"</bdi>

or even better as one of:

<bdi data-label="QS:Llang,some value"></bdi>
<i data-label="QS:Llang,some value"></i>
<u data-label="QS:Llang,some value"></u>
<u data-label-QS="Llang,some value"></u>

where those last forms do not even needs any CSS style and are warrantied to be invisible and not even break words if they occur in the middle (because the value of the label is inside a "data" attribute that is always invisible in HTML, the element is preserved by MediaWiki as well because it has a valued attribute and always intended to be processed by a machine; the data attribute has no restriction on its value in HTML, except that it cannot contain newlines in Mediawiki and cannot contain double quotes that are not HTML-encoded) ! (note the presence of delimiting quotes, notably just after the end of the value and before the closing HTML tag, so that value may still contain whitespaces; it may eventually contain line breaks, but this should not occur for translated labels intended to be used inline and not as full paragraphs.

The interest of using "bdi" instead of other inline elements (like "i" or "u") is also the fact that is tags are used between block elements ("div") MediaWiki will not generate a paragraph to contain them (such insertion would generate visible empty paragraphs. So "bdi" is still the best (and only) choice in MediaWiki

You can see the effect of using an empty "u" element with a data attribute in the middle of the following word (yes there's one, you cannot detect where, even by copy-pasting from the HTML browser window to an external plain-text editor or input field!):

extremely_lengthy

But below the use and an "u" element between two blocks is still visible as an empty paragraph:

Blue Block

Green Block

This last quirk does not occur with "bdi" instead in standard HTML (but Mediawiki still inserts an undesired dummy paragraph, with a computed content height 0, but with top and bottom margins; note that the two colored blocks have zero margins, they should be touching each other; this did not occur in the past with a former Mediawiki parser).

Blue Block

Green Block

This is a minor bug in most cases: templates can be designed to include those template-generated QStags explicitly inside a "div" (but NEVER implicitly within this template):

Blue Block
Green Block

Note that "data" attributes are standard in HTML and can be used on any HTML element. In addition they can have any suffix we want, after (an hyphen), that suffix just has to be a valid HTML identifier (so data attributes remain usable for efficient DOM searches by selectors).

In my opinion, "machine-readable" labels should not even use any HTML element, but may just generate HTML comments, if values contain any newline (However, the HTML Tidy step of MediaWiki will strip these HTML comments). Otherwise, those newlines should be escaped (e.g. as "\n", that a machine can interpret); in that case any backslash in the value should also be escaped (as "\\"), as well as tabs (as "\t"), or repeated spaces as ("\x20"), to avoid their compaction/trimming by HTML Tidy inside the embedded HTML text elements, independantly of CSS styles). Escaping should not be done using HTML character entities (these won't be differentiated by the final machine, but using a classic format using backslashes (that don't require any HTML entity, but this is transparent in the final HTML document), backslashes are easy to interpret by machines (the intended target of these QS tags). With such escaping of newlines (and some other whitespaces or controls we want to preserve), no more any problem to embed any text value within such data attributes of empty tags.

verdy_p (talk) 01:42, 10 December 2022 (UTC)[reply]