Page MenuHomePhabricator

Add ``` as shorthand for <syntaxhighlight>
Open, Needs TriagePublicFeature

Description

A common complaint in the resolution of T237267: Decide the fate of <source> was that the <syntaxhighlight> tag is long and hard to remember/type, especially for non-English-native speakers (e.g. T251116: Have a shorter name for <syntaxhighlight>). Certain flavors of Markdown (including Phabricator itself, as well as Discord) have solved this problem for some time now, via the triple backtick notation:


``` lang=html
<p><b>Foo</b> is a <a href="/Bar">bar</a></p>
```

<p><b>Foo</b> is a <a href="/Bar">bar</a></p>

Phabricator allows additional attributes related to the code block to be specified, by listing them all on the first line, separated by commas (see reference); something similar could be done to support some of the other parameters of the <syntaxhighlight> tag, though the exact set, and the separator, are left as decisions for the implementer.

See also T217944: Support backticks (`) for code samples (as in Markdown).

Event Timeline

I 100% agree that some kind of shorter syntax for <syntaxhighlight> is needed.

If you don't use lang="whatever", it also places the page in a maintenance category, until some Wikipedian comes along and adds lang="whatever". So to properly use this tag, you really need to type <syntaxhighlight lang="whatever">. Which is just a ton of typing.

Throw in the inline keyword that I use a lot, and that means even more typing: <syntaxhighlight lang="whatever" inline>

I'm getting tired of all this typing. A solution is needed.

@cscott @ssastry Wondering if you have any thoughts on this front. As far as I know, it is not currently possible to extend the wikitext tokeniser from an extension right ? But maybe we can have ` generate <code>, and then have a hook to intercept that and be fed to SyntaxHighlight ?

This is still on my mind two years later.

If I were designing wiki syntax from scratch, I'd say copy something industry standard like Reddit/Discord/GitHub markdown, which uses single backticks for one line code, and triple backticks for code blocks. But implementing backticks would likely mess up a bunch of existing wikicode that uses backticks. And it would be complicated to code, likely adding a completely new syntax to wikicode.

So at this point, I think the best solution to get this ticket moving is the following:

  • <shi> as an alias of <syntaxhighlight inline>
  • <sh> as an alias of <syntaxhighlight>

These are so much shorter and easier to type than the existing solutions of <code><nowiki>, <syntaxhighlight inline>, and <syntaxhighlight>. These would also still support parameters such as lang, while keeping the tag length reasonable. For example, <sh lang="js">.

Change #1015469 had a related patch set uploaded (by Novem Linguae; author: Novem Linguae):

[mediawiki/extensions/SyntaxHighlight_GeSHi@master] Add <sh> and <shi> parser tags

https://gerrit.wikimedia.org/r/1015469

Abdollmjjedloveanan triaged this task as Unbreak Now! priority.
Abdollmjjedloveanan set Due Date to Fri, Mar 29, 12:00 AM.
Novem_Linguae lowered the priority of this task from Unbreak Now! to Needs Triage.
Novem_Linguae removed Due Date.