void AnnotateMappingAndConvertToXhtml(ContentsMapping chapterMapping) { var xhtmlParagraphs = new List <XElement>(); foreach (var plainTextLine in chapterMapping.PlainTextContent) { foreach (var sentence in _sentenceBreaker.BreakToSentences(plainTextLine)) { IList <string> lines; using (var reader = _mecabBackend.ParseText(sentence)) { lines = _reader.ReadResponse(reader); } var words = new List <WordInfo>(); foreach (var line in lines) { var word = _parser.ParseWord(line); word.Translation = _dicReader.Lookup(word.RootForm); words.Add(word); } xhtmlParagraphs.Add(_xhtmlMaker.MakeParagraph(words.Select(w => _xhtmlMaker.MakeWord(w)))); xhtmlParagraphs.Add(_xhtmlMaker.MakeContextHelpParagraph(words.DistinctBy(w => w.Text))); words.Clear(); } } chapterMapping.XhtmlContent = _xhtmlMaker.MakeRootNode(xhtmlParagraphs); }
public void MakeDocumentShouldReturnXHtml() { var expected = JoinWithNewLines( "<html xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:m=\"http://www.w3.org/1998/Math/MathML\" xmlns:epub=\"http://www.ipdf.org/2007/ops\" xml:lang=\"ru\" xmlns=\"http://www.w3.org/1999/xhtml\">", " <head>", " <meta http-equiv=\"Content-Type\" content=\"application/xhtml+xml; charset=utf-8\" />", " <link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\" />", " <title>JpHtml</title>", " </head>", " <body>foo</body>", "</html>"); var actual = _maker.MakeRootNode(new List <XText> { new XText("foo") }); AssertEqualNodes(expected, actual); }