Bloom.CollectionTab.LibraryModel.GetBookReplacedWithTemplate C# (CSharp) Method

GetBookReplacedWithTemplate() private static method

Does some pre-processing on reader files
private static GetBookReplacedWithTemplate ( string bookPath ) : string
bookPath string
return string
        private static string GetBookReplacedWithTemplate(string bookPath)
        {
            //TODO: the following, which is the original code before late in 3.6, just modified the tags in the HTML
            //Whereas currently, we use the meta.json as the authoritative source.
            //TODO Should we just get rid of these tags in the HTML? Can they be accessed from javascript? If so,
            //then they will be needed eventually (as we involve c# less in the UI)
            var text = RobustFile.ReadAllText(bookPath, Encoding.UTF8);
            // Note that we're getting rid of preceding newline but not following one. Hopefully we cleanly remove a whole line.
            // I'm not sure the </meta> ever occurs in html files, but just in case we'll match if present.
            var regex = new Regex("\\s*<meta\\s+name=(['\\\"])lockedDownAsShell\\1 content=(['\\\"])true\\2>(</meta>)? *");
            var match = regex.Match(text);
            if (match.Success)
                text = text.Substring(0, match.Index) + text.Substring(match.Index + match.Length);

            // BL-2476: Readers made from BloomPacks should have the formatting dialog disabled
            regex = new Regex("\\s*<meta\\s+name=(['\\\"])pageTemplateSource\\1 content=(['\\\"])(Leveled|Decodable) Reader\\2>(</meta>)? *");
            match = regex.Match(text);
            if (match.Success)
            {
                // has the lockFormatting meta tag been added already?
                var regexSuppress = new Regex("\\s*<meta\\s+name=(['\\\"])lockFormatting\\1 content=(['\\\"])(.*)\\2>(</meta>)? *");
                var matchSuppress = regexSuppress.Match(text);
                if (matchSuppress.Success)
                {
                    // the meta tag already exists, make sure the value is "true"
                    if (matchSuppress.Groups[3].Value.ToLower() != "true")
                    {
                        text = text.Substring(0, matchSuppress.Groups[3].Index) + "true"
                            +  text.Substring(matchSuppress.Groups[3].Index + matchSuppress.Groups[3].Length);
                    }
                }
                else
                {
                    // the meta tag has not been added, add it now
                    text = text.Insert(match.Index + match.Length,
                        "\r\n    <meta name=\"lockFormatting\" content=\"true\"></meta>");
                }
            }

            return text;
        }