Difference between revisions of "Web Browser Syntax Highlighting"

From Syslinux Wiki
Jump to: navigation, search
m (Typos. Update and correct link.)
 
Line 1: Line 1:
Web Browser Syntax Highlighting adds color coded syntax highlighting to the configuration file when it is viewed in a browser. This is accomplished by adding 5 comments before an existing configuration and 1 comment after it. Together these comments add HTML and JavaScript which will provide compatibility with web based viewing without effecting functionality. Because these changes are comments, Syslinux will ignore them and the configuration file functional. The following article is based on this  [http://syslinux.zytor.com/archives/2010-September/015252.html mailing list post].
+
Web Browser Syntax Highlighting adds color coded syntax highlighting to the configuration file when it is viewed in a browser. This is accomplished by adding 5 comments before an existing configuration and 1 comment after it. Together these comments add HTML and JavaScript which will provide compatibility with web based viewing without effecting functionality. Because these changes are comments, Syslinux will ignore them and the configuration file will still be functional. The following article is based on this  [http://www.syslinux.org/archives/2010-September/015590.html mailing list post].
  
 
==Adding Web Browser Syntax Highlighting==
 
==Adding Web Browser Syntax Highlighting==
There are two ways to add syntax highlighting. If you have internet access you can copy and paste the lines below which point to the http://pileus.tinflower.com server, no modification needed. This will downloads the javascript and css from the internet each time you view the file. If you want or need to host those files locally you can download [http://alexgorbatchev.com/SyntaxHighlighter/ SyntaxHighlighter] then add the [http://pileus.tinflower.com/webroot/syntaxhighlighter/scripts/shBrushSyslinux.js shBrushSyslinux.js brush file] to
+
There are two ways to add syntax highlighting. If you have internet access you can copy and paste the lines below which point to the http://pileus.tinflower.com server, no modification needed. This will download the javascript and css from the internet each time you view the file. If you want or need to host those files locally you can download [http://alexgorbatchev.com/SyntaxHighlighter/ SyntaxHighlighter] then add the [http://pileus.tinflower.com/webroot/syntaxhighlighter/scripts/shBrushSyslinux.js shBrushSyslinux.js brush file] to
 
the 'scripts' subfolder. Add the lines below and adjust the 4 URLs to
 
the 'scripts' subfolder. Add the lines below and adjust the 4 URLs to
 
match your hosting location.  
 
match your hosting location.  

Latest revision as of 14:16, 16 August 2014

Web Browser Syntax Highlighting adds color coded syntax highlighting to the configuration file when it is viewed in a browser. This is accomplished by adding 5 comments before an existing configuration and 1 comment after it. Together these comments add HTML and JavaScript which will provide compatibility with web based viewing without effecting functionality. Because these changes are comments, Syslinux will ignore them and the configuration file will still be functional. The following article is based on this mailing list post.

Adding Web Browser Syntax Highlighting

There are two ways to add syntax highlighting. If you have internet access you can copy and paste the lines below which point to the http://pileus.tinflower.com server, no modification needed. This will download the javascript and css from the internet each time you view the file. If you want or need to host those files locally you can download SyntaxHighlighter then add the shBrushSyslinux.js brush file to the 'scripts' subfolder. Add the lines below and adjust the 4 URLs to match your hosting location.

 # <html><head><script type="text/javascript" src="http://pileus.TinFlower.com/webroot/syntaxhighlighter/scripts/shCore.js"></script>
 # <script type="text/javascript" src="http://pileus.TinFlower.com/webroot/syntaxhighlighter/scripts/shBrushSyslinux.js"></script>
 # <link href="http://pileus.TinFlower.com/webroot/syntaxhighlighter/styles/shCoreFadeToGrey.css" rel="stylesheet" type="text/css" />
 # <link href="http://pileus.TinFlower.com/webroot/syntaxhighlighter/styles/shThemeFadeToGrey.css" rel="stylesheet" type="text/css" />
 # </head><body><pre class="brush: syslinux;">

...Normal Syslinux configuration here...

 # </pre><script type="text/javascript">SyntaxHighlighter.all();</script></body></html>

How it Works

The top four comments are a basic HTML <head></head> section. These load the open source SyntaxHighlighter from the server. The fifth comment starts a HTML <body> and opens a <pre tag. This tells the browser that the rest of the configuration is formatted plain text. This prevents the browser from wrapping lines and otherwise destroying the formatting of the file and alto tells the highlighter what language to to look for when performing highlights.

The last line tells SyntaxHighlighter to actually do the highlighting and closes the <pre>, <body>, and the <HTML> tags.