[[PageOutline(2-5,Contents,pullout)]] = Code example box with syntax highlighting = == Description == The CodeExampleMacro renders a code example box that supports syntax highlighting. It support three types of examples: simple, correct, and incorrect. Features: * The '''SELECT ALL''' link highlights all of the code in the box to simplify the copy and paste action. * A mouse click on the header (title) will show or hide the code block. * Code from the repository can be displayed using TracLinks syntax. The multiple repository configuration (Trac >= 0.12) is supported. All rights reserved by [http://codedgers.com Codedgers Inc.] == Bugs/Feature Requests == Existing bugs and feature requests for CodeExampleMacro are [report:9?COMPONENT=CodeExampleMacro here]. If you have any issues, create a [http://trac-hacks.org/newticket?component=CodeExampleMacro&owner=nuald new ticket]. == Download == Download the zipped source from [download:codeexamplemacro here]. == Source == You can check out CodeExampleMacro from [http://trac-hacks.org/svn/codeexamplemacro here] using Subversion, or [source:codeexamplemacro browse the source] with Trac. == Example == The simple example: {{{ {{{ #!CodeExample #!python @staticmethod def get_templates_dirs(): """ Notify Trac about templates dir. """ from pkg_resources import resource_filename return [resource_filename(__name__, 'templates')] }}} }}} will be rendered as: [[Image(example1.png)]] The incorrect example: {{{ {{{ #!CodeExample ## type = bad #!haskell fibs = 0 : 1 : [ a + b | a <- fibs | b <- tail fibs ] }}} }}} will be rendered as: [[Image(example2.png)]] The correct example: {{{ {{{ #!CodeExample ## type = good #!haskell fibs = 0 : 1 : zipWith (+) fibs (tail fibs) }}} }}} will be rendered as: [[Image(example3.png)]] There is also support for getting sources from the repository: {{{ {{{ #!CodeExample ## path=GPGMail/Source/GPGMailPreferences.m ## regex=".*updater\s*{" ## lines=3 #!objective-c }}} }}} will be rendered as: [[Image(example4.png)]] Parameters: * '''type''' - (optional) a type of the example: simple (default), good, bad * '''title''' - (optional) the title of the example * '''path''' - (optional) a file in the repository (using TracLinks format for source code) * '''repo''' - (optional) repository to use (Trac 0.12 and upper only) * '''regex''' - (optional) a regular expression indicates where to start an example * '''lines''' - (optional) number of lines to show == Recent Changes == [[ChangeLog(codeexamplemacro, 3)]] == Author/Contributors == '''Author:''' [wiki:nuald] [[BR]] '''Maintainer:''' [wiki:nuald] [[BR]] '''Contributors:'''