Для того, что бы реализовать подсветку синтаксиса на Blogger.com для языков программирования переходим в меню "Шаблон".
Нажимаем кнопку "Изменить HTML".
Теперь в зависимости от типа шаблона ("Простой" или "Динамический") необходимо добавить скрипты.
Для простого шаблона, в начале кода, перед тегом "</head>" вставляем:
1. http://oneqonea.blogspot.com/2012/04/how-do-i-add-syntax-highlighting-to-my.html
2. http://ufasoli.blogspot.com/2014/01/syntaxhighlighter-and-blogger-dynamic_20.html
3. http://alexgorbatchev.com/SyntaxHighlighter/manual/configuration/
Теперь в зависимости от типа шаблона ("Простой" или "Динамический") необходимо добавить скрипты.
Для простого шаблона, в начале кода, перед тегом "</head>" вставляем:
<!-- Syntax Highlighter Additions START --> <link href="http://alexgorbatchev.com/pub/sh/current/styles/shCore.css" rel="stylesheet" type="text/css" /> <link href="http://alexgorbatchev.com/pub/sh/current/styles/shThemeEmacs.css" rel="stylesheet" type="text/css" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushAS3.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushBash.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushColdFusion.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushDelphi.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushDiff.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushErlang.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushGroovy.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJavaFX.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPerl.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPlain.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPowerShell.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushScala.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushVb.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js" type="text/javascript" /> <script language="javascript" type="text/javascript"> SyntaxHighlighter.config.bloggerMode = true; SyntaxHighlighter.all(); </script> <!-- Syntax Highlighter Additions END --> </head>Для динамического шаблона, в начале кода, сразу же после тега "<head>" вставляем:
<head> <!-- CSS resources --> <link href='http://alexgorbatchev.com/pub/sh/2.1.382/styles/shCore.css' rel='stylesheet' type='text/css'/> <link href='http://alexgorbatchev.com/pub/sh/2.1.382/styles/shThemeMidnight.css' rel='stylesheet' type='text/css'/>и в конце документа, перед тегом "</body>" вставляем:
<!-- Javascript resources --> <script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shCore.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushJava.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushSql.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushXml.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushXml.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushBash.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushJScript.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushPerl.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushPlain.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushScala.js' type='text/javascript'/> <script language='javascript' type='text/javascript'> // define usual options SyntaxHighlighter.config.bloggerMode = true; SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/2.1.382/scripts/clipboard.swf'; // set timeout and iterate through the appropriate html items window.setTimeout(function() { jQuery( "pre" ).each(function( index ) { SyntaxHighlighter.highlight(undefined, jQuery( this ).get(0)); }); }, 3000); </script> </body>Для того что бы использовать подсветку синтаксиса в своих статьях перейдите в режим редактирования сообщений в виде HTML и вставьте следующий код:
<pre class="brush:java;wrap-lines:false;toolbar:false;gutter:false;"> public void butClick(View v) { // Определяем какой View вызвал событие switch (v.getId()) { case R.id.button1: .... break; case R.id.button2: .... break; } } </pre>Источники:
1. http://oneqonea.blogspot.com/2012/04/how-do-i-add-syntax-highlighting-to-my.html
2. http://ufasoli.blogspot.com/2014/01/syntaxhighlighter-and-blogger-dynamic_20.html
3. http://alexgorbatchev.com/SyntaxHighlighter/manual/configuration/