MCPcopy Create free account
hub / github.com/unconed/TermKit / stripCData

Function stripCData

HTML/external/syntaxhighlighter_3.0.83/src/shCore.js:1091–1117  ·  view source on GitHub ↗

* Strips <![CDATA[]]> from content because it should be used * there in most cases for XHTML compliance. * @param {String} original Input code. * @return {String} Returns code without leading <![CDATA[]]> tags.

(original)

Source from the content-addressed store, hash-verified

1089 * @return {String} Returns code without leading <![CDATA[]]> tags.
1090 */
1091function stripCData(original)
1092{
1093 var left = '<![CDATA[',
1094 right = ']]>',
1095 // for some reason IE inserts some leading blanks here
1096 copy = trim(original),
1097 changed = false,
1098 leftLength = left.length,
1099 rightLength = right.length
1100 ;
1101
1102 if (copy.indexOf(left) == 0)
1103 {
1104 copy = copy.substring(leftLength);
1105 changed = true;
1106 }
1107
1108 var copyLength = copy.length;
1109
1110 if (copy.indexOf(right) == copyLength - rightLength)
1111 {
1112 copy = copy.substring(0, copyLength - rightLength);
1113 changed = true;
1114 }
1115
1116 return changed ? copy : original;
1117};
1118
1119
1120/**

Callers 1

shCore.jsFile · 0.85

Calls 1

trimFunction · 0.85

Tested by

no test coverage detected