Example #1
0
        public string Format(string text)
        {
            var index    = 0;
            var joinedJs = new StringBuilder();
            var html     = _rexJs.Replace(text, m =>
            {
                if (string.IsNullOrWhiteSpace(m.Value))
                {
                    return(m.Value);
                }

                if (joinedJs.Length > 0)
                {
                    joinedJs.AppendLine($"function _____split{index++}_____(){{}}");
                }
                joinedJs.AppendLine(m.Value);

                return("_____split_____");
            });
            var fmtedJs = _jsFotmatter.Format(joinedJs.ToString());
            var jsArr   = _rexJsSplit.Split(fmtedJs);

            index = 0;
            html  = _rexJs.Replace(html, m =>
            {
                if (string.IsNullOrWhiteSpace(m.Value))
                {
                    return(m.Value);
                }

                return("\r\n" + _jsFotmatter.AppendCopyright(jsArr[index++]));
            });

            html = _rexCss.Replace(html, m =>
            {
                if (string.IsNullOrWhiteSpace(m.Value))
                {
                    return(m.Value);
                }
                else
                {
                    return("\r\n" + _cssFotmatter.AppendCopyright(_cssFotmatter.Format(m.Value)));
                }
            });

            return(html);
        }