Lint errors
editThis template is causing missing end tag, stripped tag, and misnested tag lint errors, and it seems that this is associated with line breaks or multiple blocks in either or both of the main parameters. Here are some pages that use this templates and have such errors:
- Talk:Sri Sathya Sai International Organization: Missing end tag and Stripped tags for
<ins>...</ins>
. - Talk:IHH Healthcare: Missing end tag and Stripped tags for
<ins>...</ins>
. - Talk:Dog food: Missing end tag and Stripped tags for
<del>...</del>
. - Talk:American Foundation for Suicide Prevention: HTML5-misnesting and Stripped tags for
<ins>...</ins>
. - Template talk:Non-free 2D art: HTML5-misnesting and Stripped tags for
<ins>...</ins>
.
If this can fixed, it should be fixed. If it can't be fixed, it should be documented what markup causes these problems. —Anomalocaris (talk) 00:34, 7 October 2023 (UTC)
Jonesey95: Thank you for fixing Template:TextDiff/doc to acknowledge that this template is good for inline use only. Unfortunately, it is already widely deployed with multi-paragraph arguments, so it would be good if somebody gets this thing to work in such contexts. —Anomalocaris (talk) 22:10, 3 December 2023 (UTC)
- As you might have seen, I did some experimenting in the template sandbox and created a testcases page. It was not fruitful, for the most part. I don't know enough Lua or CSS, one of which might be able to help resolve the problem, to install a fix in the module. – Jonesey95 (talk) 23:29, 3 December 2023 (UTC)
- I am returning to this issue after some time. It still exists. I have replaced the minimal block-content test case with a smaller example that still shows an error. The relevant bit of the rendered wikitext appears to be an untranslated line break after "1947)":
<div style="word-wrap: break-word; direction: ltr;">Jane Doe<ins class="diffchange diffchange-inline" style="background: var(--background-color-content-added,#a3d3ff); color: inherit; padding: 0.25em 0; font-weight: bold; text-decoration: initial;"> </ins><ins class="diffchange diffchange-inline" style="background: var(--background-color-content-added,#a3d3ff); color: inherit; padding: 0.25em 0; font-weight: bold; text-decoration: initial;">(born</ins> <ins class="diffchange diffchange-inline" style="background: var(--background-color-content-added,#a3d3ff); color: inherit; padding: 0.25em 0; font-weight: bold; text-decoration: initial;">1947)</ins><ins class="diffchange diffchange-inline" style="background: var(--background-color-content-added,#a3d3ff); color: inherit; padding: 0.25em 0; font-weight: bold; text-decoration: initial;">  </ins><ins class="diffchange diffchange-inline" style="background: var(--background-color-content-added,#a3d3ff); color: inherit; padding: 0.25em 0; font-weight: bold; text-decoration: initial;">==Early</ins>
- I am returning to this issue after some time. It still exists. I have replaced the minimal block-content test case with a smaller example that still shows an error. The relevant bit of the rendered wikitext appears to be an untranslated line break after "1947)":
- Note the
 
(an encoded space followed by an unencoded space) followed by a line break in the rendered code, then </ins>
, which represents two encoded line breaks and then a closing ins tag.
- Note the
- The unencoded line break inside the
<ins>...</ins>
tag, which is an inline-only tag, as far as I know, may be the problem. I have a hypothesis that if the module code could encode the line break, the<ins>...</ins>
tags would no longer contain line breaks and would not complain. If there are any Lua coders who can take a look at the sandbox module code and figure out a way to test this hypothesis, that may be helpful.
- The unencoded line break inside the
- The translation from plain text to encoded text may be performed by the Lua mw.text.nowiki function, if I am reading the code correctly. It may not be encoding enough of the line breaks. – Jonesey95 (talk) 01:54, 15 November 2024 (UTC)
- I'll try to look at this over the weekend. Meanwhile, see User:Johnuniq/sandbox2 where I posted just the minimal test using {{Text diff/sandbox}}, then added something to show the wikitext from the template (it looks ok on a big screen). Page information shows stripped-tag and html5-misnesting errors for ins. Johnuniq (talk) 04:47, 15 November 2024 (UTC)
- Thanks for looking at it. I wonder if that Module:dump output is accurate. It does not have a line break in the code after "1947)" but Special:ExpandTemplates does have a line break, which is where the stripped-tag and html5-misnesting errors for
>  </ins>
<ins>...</ins>
are. – Jonesey95 (talk) 04:55, 15 November 2024 (UTC)- Hmmm, it might not be accurate about that because dumphtml tries to show formatted html and it could be skipping a newline. I'll think about that. Johnuniq (talk) 05:53, 15 November 2024 (UTC)
- Thanks for looking at it. I wonder if that Module:dump output is accurate. It does not have a line break in the
- I'll try to look at this over the weekend. Meanwhile, see User:Johnuniq/sandbox2 where I posted just the minimal test using {{Text diff/sandbox}}, then added something to show the wikitext from the template (it looks ok on a big screen). Page information shows stripped-tag and html5-misnesting errors for ins. Johnuniq (talk) 04:47, 15 November 2024 (UTC)
- The translation from plain text to encoded text may be performed by the Lua mw.text.nowiki function, if I am reading the code correctly. It may not be encoding enough of the line breaks. – Jonesey95 (talk) 01:54, 15 November 2024 (UTC)
This has also been previously brough up at Wikipedia talk:Linter/Archive 3#del and ins tag errors. All I really remember is something about newlines being part of the difference was causing issues, though I don't remember (or have) any ideas for a fix. Aidan9382 (talk) 08:06, 15 November 2024 (UTC)
- I've come up with a potential fix idea here. Not sure if it's the cleanest way of fixing it, but it seems to solve the linter issues and still seems to render fine, if a little bit different (stacks of newlines are a bit shorter). Aidan9382 (talk) 08:15, 15 November 2024 (UTC)
- That looks like a nice fix that targets the problem and does not affect anything else. It also appears to avoid displaying a spurious extra line break in the resulting diff. In the minimal case, the live template shows three line breaks after "Doe was born" in the diff, but the input contains only two line breaks, as does the sandbox diff. So the fix appears to be correcting a Linter error that was also resulting in a display error; two fixes! I'm happy with this change. I'll let Johnuniq take a look at it before making it live. – Jonesey95 (talk) 14:01, 15 November 2024 (UTC)
- I did a trivial edit to update how the original MediaWiki author appears for compatibility with c:Module:Diff, and to remove trailing whitespace. Should I fix the indents to use tabs? That would be more normal but would complicate comparing enwiki version with c:Module:Diff. I will need another 24 hours to look at the substantive issues. Johnuniq (talk) 02:31, 16 November 2024 (UTC)
- Rather than doing any work, I fixed the indents. Revert if unwanted. Johnuniq (talk) 03:48, 16 November 2024 (UTC)
- I did a trivial edit to update how the original MediaWiki author appears for compatibility with c:Module:Diff, and to remove trailing whitespace. Should I fix the indents to use tabs? That would be more normal but would complicate comparing enwiki version with c:Module:Diff. I will need another 24 hours to look at the substantive issues. Johnuniq (talk) 02:31, 16 November 2024 (UTC)
- That looks like a nice fix that targets the problem and does not affect anything else. It also appears to avoid displaying a spurious extra line break in the resulting diff. In the minimal case, the live template shows three line breaks after "Doe was born" in the diff, but the input contains only two line breaks, as does the sandbox diff. So the fix appears to be correcting a Linter error that was also resulting in a display error; two fixes! I'm happy with this change. I'll let Johnuniq take a look at it before making it live. – Jonesey95 (talk) 14:01, 15 November 2024 (UTC)
Block content aligned vertically at the top
editJust for the record, if we are going to support block content, it seemed to me that both blocks should start their text at the top of the table cell, instead of being aligned vertically in the center. I have made a minor change to the td style in the sandbox. You can see the effect in the minimal block test case. This change should have no effect on in-line diffs or on the Linter error described above. – Jonesey95 (talk) 14:08, 16 November 2024 (UTC)
- I have finished examining the code and Module:Diff/sandbox is ready to be deployed. I haven't penetrated the module's innermost secrets but I got a fair understanding of what it is doing. I think Aidan9382's fix is all that's required for now. I wondered whether the algorithm could be improved to properly handle multiple lines but I think that would require quite a lot of pain. I gave up trying to fix the problem apparent in the simpler multiline demo at User:Johnuniq/sandbox2 (it does not show "def hello" as being the same because some excess spaces confuse it). The module works well for its intended use. Johnuniq (talk) 02:50, 17 November 2024 (UTC)
- I have updated the live module. Please report any errors here. Thanks to both of you for your clever and quick work! – Jonesey95 (talk) 04:21, 17 November 2024 (UTC)
The highlighting doesn't always match MediaWiki's
editExample: [1]
In the example, the template currently highlights "correspondence)" and the comma. However, both were untouched and should thus probably not be highlighted. MediaWiki gets it right, the template currently doesn't. ~ ToBeFree (talk) 07:09, 8 July 2024 (UTC)