diff --git a/include/tidyenum.h b/include/tidyenum.h
index 1028e33..4f74e8d 100644
--- a/include/tidyenum.h
+++ b/include/tidyenum.h
@@ -213,6 +213,7 @@ typedef enum
TidyPPrintTabs, /**< Indent using tabs istead of spaces */
TidySkipNested, /**< Skip nested tags in script and style CDATA */
TidyStrictTagsAttr, /**< Ensure tags and attributes match output HTML version */
+ TidyEscapeScripts, /**< Escape items that look like closing tags in script tags */
N_TIDY_OPTIONS /**< Must be last */
} TidyOptionId;
diff --git a/src/config.c b/src/config.c
index aba6895..ddb677c 100644
--- a/src/config.c
+++ b/src/config.c
@@ -323,6 +323,7 @@ static const TidyOptionImpl option_defs[] =
{ TidyPPrintTabs, PP, "indent-with-tabs", BL, no, ParseTabs, boolPicks }, /* 20150515 - Issue #108 */
{ TidySkipNested, MU, "skip-nested", BL, yes, ParseBool, boolPicks }, /* 1642186 - Issue #65 */
{ TidyStrictTagsAttr, MU, "strict-tags-attributes", BL, no, ParseBool, boolPicks }, /* 20160209 - Issue #350 */
+ { TidyEscapeScripts, PP, "escape-scripts", BL, yes, ParseBool, boolPicks }, /* 20160227 - Issue #348 */
{ N_TIDY_OPTIONS, XX, NULL, XY, 0, NULL, NULL }
};
diff --git a/src/language_en.h b/src/language_en.h
index 1c25b76..db46b74 100644
--- a/src/language_en.h
+++ b/src/language_en.h
@@ -2068,6 +2068,11 @@ static languageDefinition language_en = { whichPluralForm_en, {
"
"
"When set to no, these checks are not performed. "
},
+ {
+ TidyEscapeScripts, 0,
+ "This option causes items that look like closing tags, like </g
to be "
+ "escaped to <\\/g
. Set this option to 'no' if you do not want this."
+ },
/********************************************************
** Console Application
diff --git a/src/lexer.c b/src/lexer.c
index 5da6074..097a1bc 100644
--- a/src/lexer.c
+++ b/src/lexer.c
@@ -2285,8 +2285,10 @@ static Node *GetCDATA( TidyDocImpl* doc, Node *container )
SetLexerLocus( doc, lexer );
lexer->columns -= 3;
- /* if javascript insert backslash before / */
- if (TY_(IsJavaScript)(container))
+ /*\ if javascript insert backslash before /
+ * Issue #348 - Add option, escape-scripts, to skip
+ \*/
+ if ((TY_(IsJavaScript)(container)) && cfgBool(doc, TidyEscapeScripts))
{
/* Issue #281 - only warn if adding the escape! */
TY_(ReportError)(doc, NULL, NULL, BAD_CDATA_CONTENT);