Page MenuHomePhabricator

Use <code> instead of <syntaxhighlight>
Open, Needs TriagePublicFeature

Description

Feature summary (what you would like to be able to do and where):
Now we have two tags that do exactly the same thing - highlight the code. Only one does not have normal functionality, and the second has a too long tag. It seems to me that they need to be combined so that users do not get confused which of the tags to use.
https://www.mediawiki.org/wiki/User:Iniquity/code

Use case(s) (list the steps that you performed to discover that problem, and describe the actual underlying problem which you want to solve. Do not describe only a solution):
I want to use a small convenient tag that does not take long to write and which does not have to be selected from a variety of tags.

Benefits (why should this be implemented?):

  1. Users will not get confused by tags
  2. We remove duplication of functionality

Event Timeline

I don't think the two tags are the same.

  • The <code> element is a standard part of HTML and doesn't provide highlighting. It's an inline element, and can be used in more situations than just syntax highlighting.
  • <syntaxhighlight> on the other hand is a specific MediaWiki extension and is a block element. The HTML equivalent is <pre>, which is used in some situations.

The fact that syntaxhighlight is a long word to write out has come up previously (e.g. T314918, T251116) and generally ideas to shorten it have been declined because it's possible to create a template to wrap the tag to make it easier to type.

I don't think the two tags are the same.

  • The <code> element is a standard part of HTML and doesn't provide highlighting. It's an inline element, and can be used in more situations than just syntax highlighting.
  • <syntaxhighlight> on the other hand is a specific MediaWiki extension and is a block element. The HTML equivalent is <pre>, which is used in some situations.

The fact that syntaxhighlight is a long word to write out has come up previously (e.g. T314918, T251116) and generally ideas to shorten it have been declined because it's possible to create a template to wrap the tag to make it easier to type.

Why not make syntax an add-on over <code> tag. We also save HTML5 semantic yes.

I don't think extensions should hijack existing HTML elements like that. For inline code highlighting, the inline property can be used, e.g. <syntaxhighlight lang="php" inline>…</syntaxhighlight>.

I don't think extensions should hijack existing HTML elements like that. For inline code highlighting, the inline property can be used, e.g. <syntaxhighlight lang="php" inline>…</syntaxhighlight>.

Why not?:) We can use smth like <code lang-id="php"> for example.

There is another ticket discussing mapping triple ` to syntaxhighlighting, which I think is a much better idea honestly. It matches expectations that people have of other wiki link languages such as markdown, it's short, not language specific and unlikely to conflict with existing wiki text. The inline variant with ` might be a bit more difficult to introduce, but worth an investigation.

However, adding wikisyntax is difficult, especially if that syntax has to map to an extension (I don't think we have anything like that right now).

There is another ticket discussing mapping triple ` to syntaxhighlighting, which I think is a much better idea honestly. It matches expectations that people have of other wiki link languages such as markdown, it's short, not language specific and unlikely to conflict with existing wiki text. The inline variant with ` might be a bit more difficult to introduce, but worth an investigation.

However, adding wikisyntax is difficult, especially if that syntax has to map to an extension (I don't think we have anything like that right now).

T286569

<syntaxhighlight> has an inline function, which if absolutely necessary, you can wrap into a template. Right now Template:Code does that. I don't think this is a great task to take on.