Permalink
Browse files

Added support for highlighting of multiple HTML element types. Includ…

…ed "code" among default elements.
  • Loading branch information...
1 parent b7154ce commit 04e93744b15eb83de2c9e28caa4aab6707cb7506 @outis committed Jan 23, 2012
Showing with 16 additions and 3 deletions.
  1. +16 −3 scripts/shCore.js
View
@@ -75,8 +75,8 @@ var sh = {
stripBrs : false,
- /** Name of the tag that SyntaxHighlighter will automatically look for. */
- tagName : 'pre',
+ /** Name of the tag(s) that SyntaxHighlighter will automatically look for. */
+ tagName : ['pre', 'code'],
strings : {
expandSource : 'expand source',
@@ -245,11 +245,24 @@ var sh = {
*/
findElements: function(globalParams, element)
{
- var elements = element ? [element] : toArray(document.getElementsByTagName(sh.config.tagName)),
+ var elements = [],
conf = sh.config,
result = []
;
+ if (element) {
+ elements = [element];
+ } else if (typeof sh.config.tagName === 'string') {
+ elements = toArray(document.getElementsByTagName(sh.config.tagName));
+ } else {
+ var i;
+ for (i=0; i < sh.config.tagName.length; ++i) {
+ elements.push.apply(
+ elements,
+ toArray(document.getElementsByTagName(sh.config.tagName[i]))
+ );
+ }
+ }
// support for <SCRIPT TYPE="syntaxhighlighter" /> feature
if (conf.useScriptTags)
elements = elements.concat(getSyntaxHighlighterScriptTags());

0 comments on commit 04e9374

Please sign in to comment.