private string GetOneHtml(string file) { string text = File.ReadAllText(file, StringTools.ENCODING_SJIS); file = FileTools.MakeFullPath(file); string dir = Path.GetDirectoryName(file); string homeDir = Directory.GetCurrentDirectory(); Directory.SetCurrentDirectory(dir); try { foreach (StringTools.Enclosed encl in StringTools.GetAllEnclosed(text, "src=\"", "\"")) { text = this.EmbedSrcFile(text, encl.StartPtn.End, encl.EndPtn.Start); } { string[] lines = FileTools.TextToLines(text); for (int index = 0; index < lines.Length; index++) { string line = lines[index]; if (line.Contains("// @:res")) { StringTools.Enclosed encl = StringTools.GetEnclosed(line, "\"", "\""); if (encl == null) { throw new Exception("No Literal"); } line = this.EmbedSrcFile(line, encl.StartPtn.End, encl.EndPtn.Start); lines[index] = line; } } text = FileTools.LinesToText(lines); } } finally { Directory.SetCurrentDirectory(homeDir); } return(text); }
private string[] ResolveResource(string[] lines) { List <string> dest = new List <string>(); bool inScript = false; foreach (string fLine in lines) { string line = fLine; if (IsEndScript(line)) { inScript = false; } if (inScript) { if (line.EndsWith("// @res")) { StringTools.Enclosed literal = StringTools.GetEnclosed(line, "\"", "\""); string resFile = literal.Inner; resFile = Path.Combine(Path.GetDirectoryName(this.InputHtmlFile), resFile); string dataUrl = "data:" + GetFileType(resFile) + ";base64," + new Base64Unit().Encode(File.ReadAllBytes(resFile)); line = literal.Left + dataUrl + literal.Right; } dest.Add(line); } else { dest.Add(line); } if (IsStartScript(line)) { inScript = true; } } return(dest.ToArray()); }