Created
          February 11, 2012 22:53 
        
      - 
      
 - 
        
Save yihui/1804862 to your computer and use it in GitHub Desktop.  
    SyntaxHighlighter Brush for the R Language
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <script type="text/javascript"> | |
| SyntaxHighlighter.autoloader( | |
| "r path/to/your/syntaxhighlighter/scripts/shBrushR.js", | |
| "plain path/to/your/syntaxhighlighter/scripts/shBrushPlain.js", | |
| "sql path/to/your/syntaxhighlighter/scripts/shBrushSql.js", | |
| "js path/to/your/syntaxhighlighter/scripts/shBrushJScript.js", | |
| "html xml path/to/your/syntaxhighlighter/scripts/shBrushXml.js" | |
| ); | |
| SyntaxHighlighter.defaults["toolbar"] = false; | |
| SyntaxHighlighter.all(); | |
| </script> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <link rel="stylesheet" href="path/to/your/syntaxhighlighter/styles/shCore.css" type="text/css" /> | |
| <link rel="stylesheet" href="path/to/your/syntaxhighlighter/styles/shThemeDefault.css" type="text/css" /> | |
| <script type='text/javascript' src='path/to/your/syntaxhighlighter/scripts/shCore.js'></script> | |
| <script type='text/javascript' src='path/to/your/syntaxhighlighter/scripts/shAutoloader.js'></script> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <pre class="brush: r"> | |
| test.function = function(r) { | |
| return(pi * r^2) | |
| } | |
| test.function(1)</pre> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | /** | |
| * Author: Yihui Xie | |
| * URL: http://yihui.name/en/2010/09/syntaxhighlighter-brush-for-the-r-language | |
| * License: GPL-2 | GPL-3 | |
| */ | |
| SyntaxHighlighter.brushes.R = function() | |
| { | |
| var keywords = 'if else repeat while function for in next break TRUE FALSE NULL Inf NaN NA NA_integer_ NA_real_ NA_complex_ NA_character_'; | |
| var constants = 'LETTERS letters month.abb month.name pi'; | |
| this.regexList = [ | |
| { regex: SyntaxHighlighter.regexLib.singleLinePerlComments, css: 'comments' }, | |
| { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, | |
| { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, | |
| { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, | |
| { regex: new RegExp(this.getKeywords(constants), 'gm'), css: 'constants' }, | |
| { regex: /[\w._]+[ \t]*(?=\()/gm, css: 'functions' }, | |
| ]; | |
| }; | |
| SyntaxHighlighter.brushes.R.prototype = new SyntaxHighlighter.Highlighter(); | |
| SyntaxHighlighter.brushes.R.aliases = ['r', 's', 'splus']; | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
Thanks!