This blogs is a part-2 of How to add SyntaxHighlighter to Blogger where I will be testing the syntax highlighting abilities of this library.
SyntaxHighlighter provides various configuration parameters to be used with the <pre> tag.
SyntaxHighlighter provides various configuration parameters to be used with the <pre> tag.
Java (With Rulers -- not working?)
<pre code="brush: java; ruler: true;"> import java.io.*; public class HelloWorld{ public static void main(String[] args){ System.out.println("Hello World!"); } } </pre> |
1 2 3 4 5 6 7 8 | import java.util.*; import java.io.*; public class HelloWorld{ public static void main(String[] args){ System.out.println( "Hello World!" ); } } |
Python (With the first line number set to 100)
<pre class="brush: python; first-line: 100"> import os import sys import time class Box: def method1(self, x, y): try: print x, y except: pass </pre> |
100 101 102 103 104 105 106 107 108 109 | import os import sys import time class Box: def method1( self , x, y): try : print x, y except : pass |
XML (With lines 4 and 6 highlighted)
<pre class="brush: xml;highlight: [4, 6]"> <html> <head> <title>Test page</title> </head> <body> Welcome to the test page. </body> </html> </pre> |
1 2 3 4 5 6 7 8 | < html > < head > < title >Test page</ title > </ head > < body > Welcome to the test page. </ body > </ html > |
Real World Code snippet: OpenStack FWaaS Plugin
<pre class="brush: python; ruler: true; gutter: true; first-line: 10; highlight: [37,38]; smart-tabs: true; toolbar: true"> from neutron_fwaas.common import exceptions from neutron_fwaas.common import fwaas_constants from neutron_fwaas.extensions.firewall_v2 import Firewallv2PluginBase from neutron_fwaas.services.firewall.service_drivers import driver_api from neutron_fwaas.services.logapi.agents.drivers.iptables \ import driver as logging_driver LOG = logging.getLogger(__name__) @registry.has_registry_receivers class FirewallPluginV2(Firewallv2PluginBase): """Firewall v2 Neutron service plugin class""" supported_extension_aliases = [firewall_v2.ALIAS] path_prefix = firewall_v2.API_PREFIX def __init__(self): super(FirewallPluginV2, self).__init__() """Do the initialization for the firewall service plugin here.""" # Initialize the Firewall v2 service plugin service_type_manager = st_db.ServiceTypeManager.get_instance() service_type_manager.add_provider_configuration( fwaas_constants.FIREWALL_V2, provider_conf.ProviderConfiguration('neutron_fwaas')) # Load the default driver drivers, default_provider = service_base.load_drivers( fwaas_constants.FIREWALL_V2, self) LOG.info("Firewall v2 Service Plugin using Service Driver: %s", default_provider) </pre> |
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | from neutron_fwaas.common import exceptions from neutron_fwaas.common import fwaas_constants from neutron_fwaas.extensions.firewall_v2 import Firewallv2PluginBase from neutron_fwaas.services.firewall.service_drivers import driver_api from neutron_fwaas.services.logapi.agents.drivers.iptables \ import driver as logging_driver LOG = logging.getLogger(__name__) @registry .has_registry_receivers class FirewallPluginV2(Firewallv2PluginBase): """Firewall v2 Neutron service plugin class""" supported_extension_aliases = [firewall_v2.ALIAS] path_prefix = firewall_v2.API_PREFIX def __init__( self ): super (FirewallPluginV2, self ).__init__() """Do the initialization for the firewall service plugin here.""" # Initialize the Firewall v2 service plugin service_type_manager = st_db.ServiceTypeManager.get_instance() service_type_manager.add_provider_configuration( fwaas_constants.FIREWALL_V2, provider_conf.ProviderConfiguration( 'neutron_fwaas' )) # Load the default driver drivers, default_provider = service_base.load_drivers( fwaas_constants.FIREWALL_V2, self ) LOG.info( "Firewall v2 Service Plugin using Service Driver: %s" , default_provider) |
Comments