Deslasher Helper

March 20, 2001

Styled strings written by V4.0 are illegible in V4.1, because V4.1 expects one less level of backslashing. For example, what V4.0 writes out as

V4.1 expects to be

Rather than doing extensive string manipulation, this tool merely fixes those string-embedded style boxes that set FontFamily to Courier. The design allows users to extend the tool to include any specific string replacements that they would like to use.

Implementation

\(\(courierRules = {
"StyleBox[\"" -> 
"StyleBox[""
, 
"\",\nFontFamily->\"Courier\"]" -> 
"",
FontFamily->"Courier"]"
};\)\)

stringFix[s_String] := 
      StringReplace[s, courierRules]  /;  
        StringMatchQ[s, "*Courier*"]

stringFix[s_String] := s

Use

nbExpr = 
        Get["(*insert full path to notebook here*)"];

NotebookPut[
      nbExpr  /.  s_String :> stringFix[s]]