Wikipedia:Reference desk/Archives/Computing/2019 June 27

From Wikipedia, the free encyclopedia
Computing desk
< June 26 << May | June | Jul >> June 28 >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is a transcluded archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


June 27[edit]

<code> tag bug in MediaWiki - undesired splitting of content into <pre> tags[edit]

If one nests content inside a <code> tag with spaces in MediaWiki, there is a disturbing problem that the indented code becomes splitted in different <pre> tags.

You the user never created these <pre> tags, they are being parsed by MediaWiki.

  1. Using the SyntaxHighlight extension is something I don't want to do from personal reasons.
  2. Indenting with colons (:) will cause the same problem.
  • One can consider indenting with tabulation-characters but generally all keyboards don't have a key for tabulation-character and searching-finding-copying and pasting tabulation-characters repeatedly, feels bad to me. Also, using an AHk approach to create a Windows keyboard-shortcut to add a tabulation-character is nice but not a solution for Linux users.

Exampling the problem[edit]

Source code and outcome (please see source code in edit mode)[edit]

<x>

   <y>
       <z></z>
   </y>

</x>

Explanation[edit]

The code itself is not one piece but splitted to five blocks
Also, the space-indented part of the code (y and z tags) appear in a <pre> tag that I never created; I don't want this <pre> tag to be created.

My question[edit]

I want just one block, not 2 or more, just as in example source code (this is why I asked to see the source code of the example).
What can be done to prevent MediaWiki from splitting my nested code to blocks?

Consider using a <syntaxhighlight> tag instead of <code>. The latter works fine with inline text, like here in my answer, the former works with mutliple-lines blocks (and it can colour syntax). See this example, with <syntaxhighlight>:
<x>
    <y>
        <z></z>
    </y>
</x>
and this one, with <syntaxhighlight lang="xml">:
<x>
    <y>
        <z></z>
    </y>
</x>
--CiaPan (talk) 08:05, 27 June 2019 (UTC)[reply]
As of MediaWiki 1.32.0 using source tag properly requires SyntaxHighlight extension which to be honest - I don't want to use.
later edit: Nope, I was wrong, it doesn't require SyntaxHighlight but according to user:TheDJ's answer below, it is deprecated anyway.
Maybe another approach? 182.232.21.241 (talk) 08:57, 27 June 2019 (UTC)[reply]
Maybe try <pre>...? --CiaPan (talk) 09:09, 27 June 2019 (UTC)[reply]
I thought about that but I am afraid it will cause a broad problem in the long run if I use it exclusively and also change the CSS of the tag itself a bit. I need a tag suitable for code but totally "neutral". Thanks. 182.232.21.241 (talk) 09:59, 27 June 2019 (UTC)[reply]
Or maybe I'm wrong and <pre> is netural enough, although because the site is of an RTL language and <pre> should be LTRized for LTR code, I do indeed need to avoid using it... That's a tough one... 182.232.21.241 (talk) 12:08, 27 June 2019 (UTC)[reply]

Let's try this again:

  • <code> is an inline html element (so shouldn't be used for multiline blocks)
  • starting a line with an space creates an html <pre> element
  • The character : doesn't indent, it creates a list element. Don't use it for indenting other than on MediaWiki's talk pages.
  • So what you were doing was generating the expected results.
  • <source> is the deprecated wikicode syntax for <syntaxhighlight> and does code highlighting
  • <source> for this purpose is deprecated (please take note CiaPan) because it is now a valid HTML5 element with a different purpose
  • What you want is likely indeed a simple pre wrapping I think:

Code

<pre>
<x>
    <y>
        <z></z>
    </y>
</x>
</pre>

Result:

<x>
    <y>
        <z></z>
    </y>
</x>

Hope this helps, —TheDJ (talkcontribs) 09:17, 27 June 2019 (UTC)[reply]

Hello User:TheDJ, I thought about using <pre> but I am afraid it will cause a broad problem in the long run if I use it for codes all over the site and also change the CSS of the tag itself a bit (like changing margin, padding, etc).
Therefore, I need a tag suitable for code but totally "neutral". Thanks. 182.232.21.241 (talk) 10:04, 27 June 2019 (UTC)[reply]
Neutral, as in you don't want any markup ? Eh.... use a div and apply your own classes and CSS styling (white-space: pre-wrap) ? —TheDJ (talkcontribs) 12:10, 27 June 2019 (UTC)[reply]
User:TheDJ, I already tried that but sadly it's not helpful – Both the opener and the closure of the first non-HTML tag (x tag), appear as regular text in div, source, and actually any tag I tried which isn't pre. 182.232.21.241 (talk) 12:35, 27 June 2019 (UTC)[reply]
For single tags and tag pairs, use {{tag}}:
  • {{tag|pre}}<pre>...</pre>
  • {{tag|o|pre}}<pre>
  • {{tag|c|pre}}</pre>
  • {{tag|br|s}}<br />
For more complex constructs, use <syntaxhighlight>...</syntaxhighlight>. --Redrose64 🌹 (talk) 18:26, 27 June 2019 (UTC)[reply]
I say again that I don't use SyntaxHighlight - at all...
Anyway, I decided to use <pre> in the end because it's the only one that works and seems to me there shouldn't be a problem using it (I consider using a category for pages including it just in case I'll have to replace it). 182.232.16.31 (talk) 07:32, 28 June 2019 (UTC)[reply]

Erase a picture on Whatsapp[edit]

I'd like to erase for everyone (not just for me) a picture I posted yesterday on a Whatsapp group. Is there a way to do it? Thanks. --93.70.70.198 (talk) 18:28, 27 June 2019 (UTC)[reply]

You do a long press (if you have an iPhone, be careful not to trigger the "Force Touch action instead"). Then choose delete from the contextual menu. It will now be deleted on any other phone, when it connects to WhatsApp the next time. This normally only works for messages you posted yourself. See also: https://faq.whatsapp.com/en/android/26000068/TheDJ (talkcontribs) 08:32, 28 June 2019 (UTC)[reply]