use of org.eclipse.mylyn.wikitext.parser.outline.OutlineItem in project mylyn.docs by eclipse.
the class OutlineItemTest method testContains.
public void testContains() {
OutlineParser outlineParser = new OutlineParser(new TextileLanguage());
OutlineItem outline = outlineParser.parse("h1. First Header\n\nh2. First Header First Child\n\nh1. Third Header\n");
OutlineItem firstHeader = outline.getChildren().get(0);
OutlineItem secondHeader = outline.getChildren().get(1);
OutlineItem firstHeaderFirstChild = firstHeader.getChildren().get(0);
assertTrue(outline.contains(firstHeader));
assertTrue(outline.contains(secondHeader));
assertTrue(firstHeader.contains(firstHeader));
assertTrue(secondHeader.contains(secondHeader));
assertFalse(firstHeader.contains(secondHeader));
assertFalse(secondHeader.contains(firstHeader));
assertFalse(firstHeaderFirstChild.contains(firstHeader));
assertTrue(firstHeader.contains(firstHeaderFirstChild));
}
use of org.eclipse.mylyn.wikitext.parser.outline.OutlineItem in project mylyn.docs by eclipse.
the class XslfoDocumentBuilderIntegrationTest method testforTableCSSAttributes_bug336813.
public void testforTableCSSAttributes_bug336813() {
final String markup = "{| style=\"border-style: solid; border-color: #000; border-width: 1px;\"\n" + "|-\n" + "! header 1\n" + "! header 2\n" + "! header 3\n" + "|-\n" + "| row 1, cell 1\n" + "| row 1, cell 2\n" + "| row 1, cell 3\n" + "|- style=\"border-style: solid; border-color: #000; border-width: 1px;\" \n" + "| row 2, cell 1\n" + "| row 2, cell 2\n" + "| style=\"border-style: solid; border-color: #000; border-width: 1px;\" | row 2, cell 3\n" + "|}";
documentBuilder.getConfiguration().setPageNumbering(true);
documentBuilder.getConfiguration().setTitle("Title");
OutlineItem op = new OutlineParser(new MediaWikiLanguage()).parse(markup);
documentBuilder.setOutline(op);
parser.setMarkupLanguage(new MediaWikiLanguage());
parser.parse(markup, true);
final String xslfo = out.toString();
// Test for border attributes in table
assertTrue(Pattern.compile("<table-body border-color=\"#000\" border-style=\"solid\" border-width=\"1px\">").matcher(xslfo).find());
// Test for border attributes in row
assertTrue(Pattern.compile("<table-row border-color=\"#000\" border-style=\"solid\" border-width=\"1px\">").matcher(xslfo).find());
// Test for border attributes in cell
assertTrue(Pattern.compile("<block font-size=\"10.0pt\" border-color=\"#000\" border-style=\"solid\" border-width=\"1px\">").matcher(xslfo).find());
}
use of org.eclipse.mylyn.wikitext.parser.outline.OutlineItem in project mylyn.docs by eclipse.
the class XslfoDocumentBuilderIntegrationTest method testforTableSpan_bug336813.
public void testforTableSpan_bug336813() {
final String markup = "{|\n|-\n" + "| Column 1 || Column 2 || Column 3\n" + "|-\n" + "| rowspan=\"2\"| A\n" + "| colspan=\"2\" | B\n" + "|-\n" + "| C <!-- column 1 occupied by cell A -->\n" + "| D \n" + "|-\n" + "| E\n" + "| rowspan=\"2\" colspan=\"2\" | F\n" + "|- \n" + "| G <!-- column 2+3 occupied by cell F -->\n" + "|- \n" + "| colspan=\"3\" | H\n" + "|}";
documentBuilder.getConfiguration().setPageNumbering(true);
documentBuilder.getConfiguration().setTitle("Title");
OutlineItem op = new OutlineParser(new MediaWikiLanguage()).parse(markup);
documentBuilder.setOutline(op);
parser.setMarkupLanguage(new MediaWikiLanguage());
parser.parse(markup, true);
final String xslfo = out.toString();
// Test for rowspan
assertTrue(Pattern.compile("<table-cell number-rows-spanned=\"2\" padding-left=\"2pt\" padding-right=\"2pt\" padding-top=\"2pt\" padding-bottom=\"2pt\">").matcher(xslfo).find());
// Test for colspan
assertTrue(Pattern.compile("<table-cell number-columns-spanned=\"2\" padding-left=\"2pt\" padding-right=\"2pt\" padding-top=\"2pt\" padding-bottom=\"2pt\">").matcher(xslfo).find());
}
use of org.eclipse.mylyn.wikitext.parser.outline.OutlineItem in project mylyn.docs by eclipse.
the class XslfoDocumentBuilderIntegrationTest method testForXslFoBookmarks_bug336592.
public void testForXslFoBookmarks_bug336592() {
final String markup = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n= Bookmark H1 =\n== Bookmark H2 ==\n";
documentBuilder.getConfiguration().setPageNumbering(true);
documentBuilder.getConfiguration().setTitle("Title");
OutlineItem op = new OutlineParser(new MediaWikiLanguage()).parse(markup);
documentBuilder.setOutline(op);
parser.setMarkupLanguage(new MediaWikiLanguage());
parser.parse(markup, true);
final String xslfo = out.toString();
assertTrue(Pattern.compile("<bookmark-tree>\\s*<bookmark internal-destination=\"Bookmark_H1\">\\s*<bookmark-title>Bookmark H1</bookmark-title>\\s*<bookmark internal-destination=\"Bookmark_H2\">\\s*<bookmark-title>Bookmark H2</bookmark-title>\\s*</bookmark>\\s*</bookmark>\\s*</bookmark-tree>").matcher(xslfo).find());
}
use of org.eclipse.mylyn.wikitext.parser.outline.OutlineItem in project mylyn.docs by eclipse.
the class WikiToDocTask method createToc.
private void createToc(final Path path, OutlineItem rootItem) {
SplittingMarkupToEclipseToc markupToEclipseToc = new SplittingMarkupToEclipseToc() {
@Override
protected String computeFile(OutlineItem item) {
if (item instanceof SplitOutlineItem) {
return computeTocRelativeFile(item, path);
}
return super.computeFile(item);
}
};
markupToEclipseToc.setBookTitle(path.getTitle());
markupToEclipseToc.setHtmlFile(computeTocRelativeFile(rootItem, path));
String tocContents = markupToEclipseToc.createToc(rootItem);
// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
File tocFile = new File(dest, path.name.replaceAll("[^a-zA-Z0-9]", "-") + "-toc.xml");
try {
// $NON-NLS-1$
Writer writer = new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(tocFile)), "UTF-8");
try {
writer.write(tocContents);
} finally {
writer.close();
}
} catch (IOException e) {
// $NON-NLS-1$
String message = MessageFormat.format("Cannot write {0}: {1}", tocFile, e.getMessage());
throw new BuildException(message, e);
}
}
Aggregations