public static IEnumerable<string> Convert(IEnumerable<string> inputLines) { yield return "<TAG>"; var converter = new TextComposing.IO.AozoraBunkoTextConverter(); var indentParser = new IndentParser(); foreach (var line in indentParser.ReadLines(inputLines)) { bool isSetIndent = indentParser.IsSetIndent; double textIndent = indentParser.CurrentTextIndent; double paragraphIndent = indentParser.CurrentParagraphIndent; //先頭の開始括弧に対してはさらに二分下げる。 if (line.Length >= 1 && CharacterClasses.Cl01(new UChar(line[0]))) { isSetIndent = true; textIndent += 0.5; } IExchangableText text = converter.Convert(new UString(line)); var tag = new EdicolorTagConverter(); text.Accept(tag); var result = tag.GetText(); if (isSetIndent) yield return String.Format("<IDT IL=1 UNIT=C IS={0} TS={1} BS=0.0>{2}</IDT>", textIndent, paragraphIndent, result); else yield return result; } yield return "</TAG>"; }
public IEnumerable<IParagraphModel> Import(IEnumerable<string> lines) { _isFrozen = true; try { int startIndex = GetStartLineIndex(lines); var indentParser = new IndentParser(); foreach (string line in indentParser.ReadLines(lines.Skip(startIndex))) { var textIndent = indentParser.CurrentTextIndent; var paragraphIndent = indentParser.CurrentParagraphIndent; var paragraph = BuildParagraph(new UString(line), textIndent, paragraphIndent); yield return paragraph; } } finally { _isFrozen = false; } }