{"id":46,"date":"2013-03-25T10:05:47","date_gmt":"2013-03-25T02:05:47","guid":{"rendered":"http:\/\/ynxp.net\/?p=46"},"modified":"2013-03-25T10:05:47","modified_gmt":"2013-03-25T02:05:47","slug":"wp-syntax-other-notes","status":"publish","type":"post","link":"http:\/\/ynxp.net\/?p=46","title":{"rendered":"WP-Syntax Other Notes"},"content":{"rendered":"<p>WP-Syntax provides clean syntax highlighting using GeSHi &#8212; supporting a wide range of popular languages. It supports highlighting with or without line numbers and maintains formatting while copying snippets of code from the browser.<\/p>\n<p>It avoids conflicts with other 3rd party plugins by running an early pre-filter and a late post-filter that substitutes and pulls the code snippets out first and then pushes them back in with highlighting at the end. The result is source code formatted and highlighted the way you intended.<br \/>\n<!--more--><\/p>\n<h3 id=\"Usage\">Usage<\/h3>\n<p>Wrap code blocks with\u00a0<code>&lt;pre lang=\"LANGUAGE\" line=\"1\"&gt;<\/code>\u00a0and\u00a0<code>&lt;\/pre&gt;<\/code>\u00a0where<strong>&#8220;LANGUAGE&#8221;<\/strong>\u00a0is a\u00a0<a href=\"http:\/\/qbnz.com\/highlighter\/\" rel=\"nofollow\">GeSHi<\/a>\u00a0supported language syntax. See below for a full list of supported languages. The\u00a0<code>line<\/code>\u00a0attribute is optional.<\/p>\n<h3 id=\"Supported-Languages\">Supported Languages<\/h3>\n<p>The following languages are most supported in the <code>lang<\/code> attribute:<\/p>\n<p>abap, actionscript, actionscript3, ada, apache, applescript, apt_sources, asm, <strong>asp<\/strong>, autoit, avisynth, <strong>bash<\/strong>, bf, bibtex, blitzbasic, bnf, boo, <strong>c<\/strong>, c_mac, caddcl, cadlisp, cil, cfdg, cfm, cmake, cobol, cpp-qt, <strong>cpp<\/strong>, <strong>csharp<\/strong>, <strong>css<\/strong>, d, dcs, delphi, diff, div, dos, dot, eiffel, email, erlang, fo, fortran, freebasic, genero, gettext, glsl, gml, bnuplot, groovy, haskell, hq9plus, <strong>html4strict<\/strong>, idl, ini, inno, intercal, io, <strong>java<\/strong>, <strong>java5<\/strong>, <strong>javascript<\/strong>, kixtart, klonec, klonecpp, latex, <strong>lisp<\/strong>, locobasic, lolcode lotusformulas, lotusscript, lscript, lsl2, lua, m68k, make, matlab, mirc, modula3, mpasm, mxml, <strong>mysql<\/strong>, nsis, oberon2, <strong>objc<\/strong>, ocaml-brief, ocaml, oobas, <strong>oracle11<\/strong>, oracle8, pascal, per, pic16, pixelbender, <strong>perl<\/strong>, php-brief, <strong>php<\/strong>, plsql, povray, powershell, progress, prolog, properties, providex,<strong>python<\/strong>, qbasic, <strong>rails<\/strong>, rebol, reg, robots, <strong>ruby<\/strong>, sas, scala, scheme, scilab, sdlbasic, smalltalk, smarty, <strong>sql<\/strong>, tcl, teraterm, text, thinbasic, tsql, typoscript, <strong>vb<\/strong>, <strong>vbnet<\/strong>, verilog, vhdl, vim, visualfoxpro, visualprolog, whitespace, whois, winbatch, <strong>xml<\/strong>, xorg_conf, xpp, z80<\/p>\n<p>See the <a href=\"http:\/\/qbnz.com\/highlighter\/geshi-doc.html\" rel=\"nofollow\">GeSHi Documentation<\/a> for a full list of supported languages.<\/p>\n<p>(Bold languages just highlight the more popular ones.)<\/p>\n<div id=\"foo\">\n<p><strong>Example 1: PHP, no line numbers<\/strong><\/p>\n<blockquote>\n<pre><code>&lt;pre lang=\"php\"&gt;\n&lt;div id=\"foo\"&gt;\n&lt;?php\n  function foo() {\n    echo \"Hello World!\\\\n\";\n  }\n?&gt;\n&lt;\/div&gt;\n&lt;\/pre&gt;\n<\/code><\/pre>\n<\/blockquote>\n<pre lang=\"php\">\n<div id=\"foo\">\n<?php\n  function foo() {\n    echo \"Hello World!\\\\n\";\n  }\n?>\n<\/div>\n<\/pre>\n<p><strong>Example 2: Java, with line numbers<\/strong><\/p>\n<blockquote>\n<pre><code>&lt;pre lang=\"java\" line=\"1\"&gt;\npublic class Hello {\n  public static void main(String[] args) {\n    System.out.println(\"Hello World!\");\n  }\n}\n&lt;\/pre&gt;\n<\/code><\/pre>\n<\/blockquote>\n<pre lang=\"java\" line=\"1\">\npublic class Hello {\n  public static void main(String[] args) {\n    System.out.println(\"Hello World!\");\n  }\n}\n<\/pre>\n<p><strong>Example 3: Ruby, with line numbers starting at 18<\/strong><\/p>\n<blockquote>\n<pre><code>&lt;pre lang=\"ruby\" line=\"18\"&gt;\nclass Example\n  def example(arg1)\n    return \"Hello: \" + arg1.to_s\n  end\nend\n&lt;\/pre&gt;\n<\/code><\/pre>\n<\/blockquote>\n<pre lang=\"ruby\" line=\"18\">\nclass Example\n  def example(arg1)\n    return \"Hello: \" + arg1.to_s\n  end\nend\n<\/pre>\n<p><strong>Example 4: If your code already has html entities escaped, use\u00a0<code>escaped=\"true\"<\/code>\u00a0as an option<\/strong><\/p>\n<blockquote>\n<pre><code>&lt;pre lang=\"xml\" escaped=\"true\"&gt;\n&amp;lt;xml&amp;gt;Hello&amp;lt;\/xml&amp;gt;\n&lt;\/pre&gt;\n<\/code><\/pre>\n<\/blockquote>\n<pre lang=\"xml\" escaped=\"true\">\n&lt;xml&gt;Hello&lt;\/xml&gt;\n<\/pre>\n<p><strong>Example 5: PHP, with line numbers and highlighting a specific line<\/strong><\/p>\n<blockquote>\n<pre><code>&lt;pre lang=\"php\" line=\"1\" highlight=\"3\"&gt;\n&lt;div id=\"foo\"&gt;\n&lt;?php\n  function foo() {\n    echo \"Hello World!\\\\n\";\n  }\n?&gt;\n&lt;\/div&gt;\n&lt;\/pre&gt;\n<\/code><\/pre>\n<\/blockquote>\n<pre lang=\"php\" line=\"1\" highlight=\"3\">\n<div id=\"foo\">\n<?php\n  function foo() {\n    echo \"Hello World!\\\\n\";\n  }\n?>\n<\/div>\n<\/pre>\n<p><strong>Example 6: PHP, with a caption (file and\/or file path of the source file)<\/strong><\/p>\n<blockquote>\n<pre><code>&lt;pre lang=\"php\" src\"https:\/\/github.com\/shazahm1\/Connections\/blob\/master\/connections.php\"&gt;\n&lt;div id=\"foo\"&gt;\n&lt;?php\n  function foo() {\n    echo \"Hello World!\\\\n\";\n  }\n?&gt;\n&lt;\/div&gt;\n&lt;\/pre&gt;<\/code><\/pre>\n<\/blockquote>\n<\/div>\n<h3 id=\"Styling-Guidelines\">Styling Guidelines<\/h3>\n<p>WP-Syntax colors code using the default GeSHi colors. It also uses inline styling to make sure that code highlights still work in RSS feeds. It uses a default\u00a0<code>wp-syntax.css<\/code>stylesheet for basic layout. To customize your styling, copy the default\u00a0<code>wp-content\/plugins\/wp-syntax\/wp-syntax.css<\/code>\u00a0to your theme&#8217;s template directory and modify it. If a file named\u00a0<code>wp-syntax.css<\/code>\u00a0exists in your theme&#8217;s template directory, this stylesheet is used instead of the default. This allows theme authors to add their own customizations as they see fit.<\/p>\n<h3 id=\"Advanced-Customization\">Advanced Customization<\/h3>\n<p>WP-Syntax supports a\u00a0<code>wp_syntax_init_geshi<\/code>\u00a0action hook to customize GeSHi initialization settings. Blog owners can handle the hook in a hand-made plugin or somewhere else like this:<\/p>\n<pre><code>&lt;?php\nadd_action('wp_syntax_init_geshi', 'my_custom_geshi_styles');\n\nfunction my_custom_geshi_styles(&amp;$geshi)\n{\n    $geshi-&gt;set_brackets_style('color: #000;');\n    $geshi-&gt;set_keyword_group_style(1, 'color: #22f;');\n}\n?&gt;\n<\/code><\/pre>\n<p>This allows for a great possibility of different customizations. Be sure to review the<\/p>\n","protected":false},"excerpt":{"rendered":"<p>WP-Syntax provides clean syntax highlighting using GeSH [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[],"_links":{"self":[{"href":"http:\/\/ynxp.net\/index.php?rest_route=\/wp\/v2\/posts\/46"}],"collection":[{"href":"http:\/\/ynxp.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/ynxp.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/ynxp.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/ynxp.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=46"}],"version-history":[{"count":0,"href":"http:\/\/ynxp.net\/index.php?rest_route=\/wp\/v2\/posts\/46\/revisions"}],"wp:attachment":[{"href":"http:\/\/ynxp.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=46"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/ynxp.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=46"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/ynxp.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=46"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}