Community Central
Community Central
(→‎Article highlighting: fixing displayed code)
Tag: Help
No edit summary
Tags: Source edit Mobile edit Mobile web edit Help
Line 1: Line 1:
[[File:SyntaxHighlight-Comparison.png|thumb|250px|Wikitext with and without syntax highlighting (legacy)]]
+
[[File:SyntaxHighlight-Comparison.png|thumb|250px|Wikitext with and without syntax highlighting (outdated)]]
 
'''Syntax highlighting''' is a feature designed to improve readability of code on Fandom. It takes what is written in the editor and highlights the various types of code in different colours to help a reader identify which parts do what.
 
'''Syntax highlighting''' is a feature designed to improve readability of code on Fandom. It takes what is written in the editor and highlights the various types of code in different colours to help a reader identify which parts do what.
   
Line 10: Line 10:
 
Syntax highlighting takes this code and adds blocks of colour behind the text.
 
Syntax highlighting takes this code and adds blocks of colour behind the text.
   
 
[[File:SyntaxHighlight-Wikitext.png|thumb|250px|Wikitext highlighting]]
==== UCP colors ====
 
 
Wikis colors typically vary by text color but have no actual background colors (a notable exception is for horizontal lines, which have variable background colors). Further, links adopt the link color set by [[Help:Theme Designer|Theme Designer]], and internal links have <u>underlined</u> link destinations.
[[File:SyntaxHighlight-Wikitext.png|thumb|250px|Wikitext highlighting in the UCP]]
 
In contrast to legacy, [[Help:Unified Community Platform|UCP]] colors typically vary by text color but have no actual background colors (a notable exception is for horizontal lines, which have variable background colors). Further, links adopt the link color set by [[Help:Theme Designer|Theme Designer]], and internal links have <u>underlined</u> link destinations.
 
   
 
The main text colors are:
 
The main text colors are:
Line 20: Line 19:
 
* variable grey color = comments
 
* variable grey color = comments
 
* variable red color = [[Help:magic words|magic words]], closing tags without an opening tag
 
* variable red color = [[Help:magic words|magic words]], closing tags without an opening tag
 
==== Legacy colors ====
 
[[File:SyntaxHighlight-WikitextDark.png|thumb|250px|Wikitext highlighting on a dark theme (legacy)]]
 
The main colors involved for dark theme wikis are:
 
* <span style="background-color: #44466D; color: white;">&nbsp;dark lavender&nbsp;</span> = section headings, horizontal lines, bold and italic text
 
* <span style="background-color: #245477; color: white;">&nbsp;dark blue&nbsp;</span> = internal links
 
* <span style="background-color: transparent; color: black;">&nbsp;transparent&nbsp;</span> = external links
 
* <span style="background-color: #4D1A19; color: white;">&nbsp;brown&nbsp;</span> = general wikitext
 
* <span style="background-color: #662946; color: white;">&nbsp;dark red-violet&nbsp;</span> = tags
 
* <span style="background-color: #474D23; color: white;">&nbsp;olive&nbsp;</span> = templates and HTML versions of special characters
 
The main colors involved for light theme wikis are:
 
* <span style="background-color: #E4E5F3; color: black;">&nbsp;blue-violet&nbsp;</span> = section headings, horizontal lines, bold and italic text
 
* <span style="background-color: #D9EAF6; color: black;">&nbsp;light blue&nbsp;</span> = internal links
 
* <span style="background-color: #DBECEB; color: black;">&nbsp;pale blue&nbsp;</span> = external links
 
* <span style="background-color: #F8DBDA; color: black;">&nbsp;red&nbsp;</span> = general wikitext
 
* <span style="background-color: #F6DDE9; color: black;">&nbsp;red-violet&nbsp;</span> = tags
 
* <span style="background-color: #F0EBDB; color: black;">&nbsp;grey/brown&nbsp;</span> = templates and HTML versions of special characters
 
   
 
=== Code highlighting ===
 
=== Code highlighting ===
Line 43: Line 25:
 
Beyond simple readability improvements, the highlighting will also help you spot code issues - helping to prevent JavaScript errors, for example.
 
Beyond simple readability improvements, the highlighting will also help you spot code issues - helping to prevent JavaScript errors, for example.
 
<gallery hideaddbutton="true" orientation="landscape" widths="200">
 
<gallery hideaddbutton="true" orientation="landscape" widths="200">
SyntaxHighlight-JS.png | JS syntax highlighting ([[Help:Unified Community Platform|UCP]])
+
SyntaxHighlight-JS.png | JS syntax highlighting
SyntaxHighlight-CSS.png | CSS syntax highlighting (legacy)
+
SyntaxHighlight-CSS.png | CSS syntax highlighting (outdated)
SyntaxHighlight-LuaDark.png | Lua highlighting on a dark theme (legacy)
+
SyntaxHighlight-LuaDark.png | Lua highlighting on a dark theme (outdated)
 
</gallery>
 
</gallery>
 
=== User preference ===
 
If you do not wish to use syntax highlighting, then simply visit the 'Editing' tab in your [[Help:Preferences|preferences]] and tick the "Do not show syntax highlighting in "Source mode" option. This will switch off all forms of syntax highlighting, including on CSS and JS pages.
 
 
:'''Note:''' This preference is not available in the [[Help:Unified Community Platform|UCP]].
 
   
 
== Article highlighting ==
 
== Article highlighting ==

Revision as of 14:15, 28 January 2021

SyntaxHighlight-Comparison

Wikitext with and without syntax highlighting (outdated)

Syntax highlighting is a feature designed to improve readability of code on Fandom. It takes what is written in the editor and highlights the various types of code in different colours to help a reader identify which parts do what.

It exists in three main forms - simple wikitext highlighting, CSS/JS/template/Lua page highlighting, and as a tag usable on articles.

Editor highlighting

Simple wikitext highlighting

Wikitext is the main building block of articles across Fandom, but it can often be hard to comprehend what you're seeing at a glance, especially on more complex pages.

Syntax highlighting takes this code and adds blocks of colour behind the text.

SyntaxHighlight-Wikitext

Wikitext highlighting

Wikis colors typically vary by text color but have no actual background colors (a notable exception is for horizontal lines, which have variable background colors). Further, links adopt the link color set by Theme Designer, and internal links have underlined link destinations.

The main text colors are:

  •  dodger blue  = section headings, horizontal lines, bold and italic text, general wikitext such as lists, and link anchors (e.g. [[Link#Anchor|Text]])
  •  japanese laurel  = tags and HTML entities
  • variable purple color = templates
  • variable grey color = comments
  • variable red color = magic words, closing tags without an opening tag

Code highlighting

CSS, JS, infobox template, and Lua module pages have a more advanced syntax highlighter active.

Beyond simple readability improvements, the highlighting will also help you spot code issues - helping to prevent JavaScript errors, for example.

Article highlighting

The <syntaxhighlight> tag can be used on articles to syntax highlight sections of code for readers. A rough list of supported languages can be found on MediaWiki.org.

For example, CSS highlighting:

<syntaxhighlight lang="css">
.class {
    font-size: 110%;
}
</syntaxhighlight>

creates:

.class {
    font-size: 110%;
}


Or you can enable line numbers using the line attribute:

<syntaxhighlight lang="css" line>
.class {
    font-size: 110%;
}
</syntaxhighlight>

creates:

.class {
    font-size: 110%;
}

Note that the syntax highlighting does not work when the page has been shared. If you're reading this on a wiki other than Community Central, click here for a live example.

See also

Further help and feedback