Community Central
Community Central
(→‎Editor highlighting: added the syntax highlighting colors for dark wikis)
No edit summary
Tag: Help
(11 intermediate revisions by 9 users not shown)
Line 1: Line 1:
 
[[File:SyntaxHighlight-Comparison.png|thumb|250px|Wikitext with and without syntax highlighting]]
 
[[File:SyntaxHighlight-Comparison.png|thumb|250px|Wikitext with and without syntax highlighting]]
'''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.
   
 
It exists in three main forms - simple wikitext highlighting, CSS/JS/template/Lua page highlighting, and as a tag usable on articles.
 
It exists in three main forms - simple wikitext highlighting, CSS/JS/template/Lua page highlighting, and as a tag usable on articles.
   
==Editor highlighting==
+
== Editor highlighting ==
 
=== Simple wikitext highlighting ===
 
===Simple wikitext highlighting===
 
 
[[File:SyntaxHighlight-WikitextDark.png|thumb|250px|Wikitext highlighting on a dark theme]]
 
[[File:SyntaxHighlight-WikitextDark.png|thumb|250px|Wikitext highlighting on a dark theme]]
[[Help:Wikitext|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.
+
[[Help:Wikitext|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.
 
Syntax highlighting takes this code and adds blocks of colour behind the text.
   
 
The main colors involved for dark theme wikis are:
 
The main colors involved for dark theme wikis are:
* <span style="background-color:#44466d; color:#fff;">&nbsp;dark lavender&nbsp;</span> = section headings, horizontal lines, bold and italic text
+
* <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:#fff;">&nbsp;dark blue&nbsp;</span> = internal links
+
* <span style="background-color: #245477; color: white;">&nbsp;dark blue&nbsp;</span> = internal links
* <span style="background-color:transparent; color:#000;">&nbsp;transparent&nbsp;</span> = external links
+
* <span style="background-color: transparent; color: black;">&nbsp;transparent&nbsp;</span> = external links
* <span style="background-color:#4d1a19; color:#fff;">&nbsp;brown&nbsp;</span> = general wikitext
+
* <span style="background-color: #4D1A19; color: white;">&nbsp;brown&nbsp;</span> = general wikitext
* <span style="background-color:#662946; color:#fff;">&nbsp;dark red-violet&nbsp;</span> = tags
+
* <span style="background-color: #662946; color: white;">&nbsp;dark red-violet&nbsp;</span> = tags
* <span style="background-color:#474d23; color:#fff;">&nbsp;olive&nbsp;</span> = templates and HTML versions of special characters
+
* <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:
 
The main colors involved for light theme wikis are:
* <span style="background-color:#E4E5F3; color:#000;">&nbsp;blue-violet&nbsp;</span> = section headings, horizontal lines, bold and italic text
+
* <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:#000;">&nbsp;light blue&nbsp;</span> = internal links
+
* <span style="background-color: #D9EAF6; color: black;">&nbsp;light blue&nbsp;</span> = internal links
* <span style="background-color:#DBECEB; color:#000;">&nbsp;pale blue&nbsp;</span> = external links
+
* <span style="background-color: #DBECEB; color: black;">&nbsp;pale blue&nbsp;</span> = external links
* <span style="background-color:#F8DBDA; color:#000;">&nbsp;red&nbsp;</span> = general wikitext
+
* <span style="background-color: #F8DBDA; color: black;">&nbsp;red&nbsp;</span> = general wikitext
* <span style="background-color:#F6DDE9; color:#000;">&nbsp;red-violet&nbsp;</span> = tags
+
* <span style="background-color: #F6DDE9; color: black;">&nbsp;red-violet&nbsp;</span> = tags
* <span style="background-color:#F0EBDB; color:#000;">&nbsp;grey/brown&nbsp;</span> = templates and HTML versions of special characters
+
* <span style="background-color: #F0EBDB; color: black;">&nbsp;grey/brown&nbsp;</span> = templates and HTML versions of special characters
   
  +
=== Code highlighting ===
===CSS, JS, infobox template and Lua highlighting===
 
[[Help:CSS and JS customization|CSS, JS]], [[Help:Infoboxes|infobox templates]], and [[Help:Lua|Lua module]] pages have a more advanced syntax highlighter active.
+
[[Help:CSS and JS customization|CSS, JS]], [[Help:Infoboxes|infobox template]], and [[Help:Lua|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.
 
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="250">
 
  +
SyntaxHighlight-CSS.png | CSS syntax highlighting
<gallery hideaddbutton=true>
 
File:SyntaxHighlight-CSS.png|CSS syntax highlighting
+
SyntaxHighlight-LuaDark.png | Lua highlighting on a dark theme
File:SyntaxHighlight-LuaDark.png|Lua highlighting on a dark theme
 
 
</gallery>
 
</gallery>
   
===User preference===
+
=== User preference ===
If you do not wish to use syntax highlighting, simply visit the 'Editing' tab in your [[Help:Preferences|preferences]], and tick the "Do not show syntax highlighting in Source mode" option.
+
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.
 
This will switch off all forms of syntax highlighting, including on CSS and JS pages.
   
==Article highlighting==
+
== Article highlighting ==
The &lt;syntaxhighlight> tag can be used on articles to syntax highlight sections of code for readers. A rough list of supported languages can be found [[mw:Extension:SyntaxHighlight_GeSHi#Supported_languages|here, on MediaWiki.org]].
+
The <code>&lt;syntaxhighlight&gt;</code> tag can be used on articles to syntax highlight sections of code for readers. A rough list of supported languages can be found on [[mw:Extension:SyntaxHighlight#Supported languages|MediaWiki.org]].
   
 
For example, CSS highlighting:
 
For example, CSS highlighting:
  +
 
<pre>
 
<pre>
 
<syntaxhighlight lang="css">
 
<syntaxhighlight lang="css">
 
.class {
 
.class {
font-size:110%;
+
font-size: 110%;
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
 
</pre>
 
</pre>
 
creates:
   
creates:
 
 
<syntaxhighlight lang="css">
 
<syntaxhighlight lang="css">
 
.class {
 
.class {
font-size:110%;
+
font-size: 110%;
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
   
  +
Note that the syntax highlighting does not work when the page has been [[Help:Shared_Help|shared]]. <span class="shared-only">If you're reading this on a wiki other than Community Central, click [[w:Help:Syntax highlighting#Article_highlighting|here]] for a live example.</span>
==See also==
 
  +
* [[homepage:w:User blog:Kirkburn/Syntax highlighting - helping you read and write code|Original blog post announcement]]
 
 
== See also ==
 
* [[w:User blog:Kirkburn/Syntax highlighting - helping you read and write code|Original blog post announcement]]
 
* [[wikipedia:Syntax highlighting|Syntax highlighting]] on Wikipedia
 
* [[wikipedia:Syntax highlighting|Syntax highlighting]] on Wikipedia
 
* [[Help:CSS and JS customization]] and [[Help:Lua]]
 
* [[Help:CSS and JS customization]] and [[Help:Lua]]
   
==Further help and feedback==
+
== Further help and feedback ==
 
{{Help and feedback section}}
 
{{Help and feedback section}}
 
 
[[de:Hilfe:Syntaxhervorhebung]]
 
[[de:Hilfe:Syntaxhervorhebung]]
 
[[es:Ayuda:Resaltado de sintaxis]]
 
[[es:Ayuda:Resaltado de sintaxis]]
Line 81: Line 80:
 
[[pt:Ajuda:Realce de Sintaxe]]
 
[[pt:Ajuda:Realce de Sintaxe]]
 
[[ru:Справка:Подсветка синтаксиса]]
 
[[ru:Справка:Подсветка синтаксиса]]
  +
[[tr:Yardım:Sözdizimi vurgulama]]
 
[[vi:Trợ giúp:Làm nổi cú pháp]]
 
[[vi:Trợ giúp:Làm nổi cú pháp]]
 
[[zh:Help:語法突顯]]
 
[[zh:Help:語法突顯]]
 
 
[[Category:Help]]
 
[[Category:Help]]
 
[[Category:CSS]]
 
[[Category:CSS]]

Revision as of 18:36, 22 April 2020

SyntaxHighlight-Comparison

Wikitext with and without syntax highlighting

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

SyntaxHighlight-WikitextDark

Wikitext highlighting on a dark theme

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.

The main colors involved for dark theme wikis are:

  •  dark lavender  = section headings, horizontal lines, bold and italic text
  •  dark blue  = internal links
  •  transparent  = external links
  •  brown  = general wikitext
  •  dark red-violet  = tags
  •  olive  = templates and HTML versions of special characters

The main colors involved for light theme wikis are:

  •  blue-violet  = section headings, horizontal lines, bold and italic text
  •  light blue  = internal links
  •  pale blue  = external links
  •  red  = general wikitext
  •  red-violet  = tags
  •  grey/brown  = templates and HTML versions of special characters

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.

User preference

If you do not wish to use syntax highlighting, then simply visit the 'Editing' tab in your 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.

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%;
}

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