use of org.eclipse.mylyn.wikitext.mediawiki.MediaWikiLanguage in project mylyn.docs by eclipse.
the class WikiToDocTask method markupToDoc.
private void markupToDoc(MarkupLanguage markupLanguage, Path path, String markupContent, Map<String, SplitOutlineItem> pathNameToOutline, Set<String> imageFilenames) throws BuildException {
File htmlOutputFile = computeHtmlOutputFile(path);
File pathDir = htmlOutputFile.getParentFile();
if (!pathDir.exists()) {
if (!pathDir.mkdirs()) {
throw new BuildException(// $NON-NLS-1$
MessageFormat.format(// $NON-NLS-1$
Messages.getString("WikiToDocTask_cannot_create_dest_folder"), pathDir.getAbsolutePath()));
}
}
Writer writer;
try {
// $NON-NLS-1$
writer = new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(htmlOutputFile)), "utf-8");
} catch (Exception e) {
throw new BuildException(// $NON-NLS-1$
MessageFormat.format(// $NON-NLS-1$
Messages.getString("WikiToDocTask_cannot_create_output_file"), // $NON-NLS-1$
htmlOutputFile, e.getMessage()), e);
}
try {
HtmlDocumentBuilder builder = new HtmlDocumentBuilder(writer, formatOutput);
for (Stylesheet stylesheet : stylesheets) {
HtmlDocumentBuilder.Stylesheet builderStylesheet = createBuilderStylesheet(pathDir, stylesheet);
builder.addCssStylesheet(builderStylesheet);
}
builder.setTitle(computeTitle(path));
builder.setEmitDtd(emitDoctype);
if (emitDoctype && htmlDoctype != null) {
builder.setHtmlDtd(htmlDoctype);
}
builder.setUseInlineStyles(useInlineCssStyles);
builder.setSuppressBuiltInStyles(suppressBuiltInCssStyles);
builder.setLinkRel(linkRel);
builder.setDefaultAbsoluteLinkTarget(defaultAbsoluteLinkTarget);
builder.setPrependImagePrefix(prependImagePrefix);
builder.setXhtmlStrict(xhtmlStrict);
MarkupLanguage markupLanguageClone = markupLanguage.clone();
if (markupLanguageClone instanceof MediaWikiLanguage) {
MediaWikiLanguage mediaWikiLanguage = (MediaWikiLanguage) markupLanguageClone;
mediaWikiLanguage.setPageMapping(new PathPageMapping(path, paths, pathNameToOutline));
if (imageFilenames != null) {
mediaWikiLanguage.setImageNames(imageFilenames);
}
}
SplitOutlineItem item = pathNameToOutline.get(path.name);
SplittingHtmlDocumentBuilder splittingBuilder = new SplittingHtmlDocumentBuilder();
splittingBuilder.setRootBuilder(builder);
splittingBuilder.setOutline(item);
splittingBuilder.setRootFile(htmlOutputFile);
splittingBuilder.setNavigationImages(navigationImages);
splittingBuilder.setFormatting(formatOutput);
splittingBuilder.setNavigationImagePath(computeNavigationImagePath(pathDir));
MarkupParser parser = new MarkupParser();
parser.setMarkupLanguage(markupLanguageClone);
parser.setBuilder(splittingBuilder);
parser.parse(markupContent);
} finally {
try {
writer.close();
} catch (Exception e) {
throw new BuildException(MessageFormat.format(// $NON-NLS-1$
Messages.getString("WikiToDocTask_cannot_write_output_file"), // $NON-NLS-1$
htmlOutputFile, e.getMessage()), e);
}
}
}
use of org.eclipse.mylyn.wikitext.mediawiki.MediaWikiLanguage in project mylyn.docs by eclipse.
the class XslfoDocumentBuilderIntegrationTest method testforTableRowAlign_bug336813.
public void testforTableRowAlign_bug336813() {
final String markup = "{|\n" + "|- valign=\"top\"\n |'''Row heading'''\n" + "| A longer piece of text. Lorem ipsum...\n |A shorter piece of text.\n" + "|- style=\"vertical-align: bottom;\"\n |'''Row heading'''\n" + "|A longer piece of text. Lorem ipsum... \n |A shorter piece of text.\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();
// From "valign" attribute
assertTrue(Pattern.compile("<table-row display-align=\"before\">").matcher(xslfo).find());
// From css styling
assertTrue(Pattern.compile("<table-row display-align=\"after\">").matcher(xslfo).find());
}
use of org.eclipse.mylyn.wikitext.mediawiki.MediaWikiLanguage in project mylyn.docs by eclipse.
the class ParagraphBlock method processLineContent.
@Override
public int processLineContent(String line, int offset) {
nestedStartOffset = -1;
nestedLineNumber = -1;
if (blockLineCount == 0) {
Attributes attributes = new Attributes();
builder.beginBlock(BlockType.PARAGRAPH, attributes);
}
if (markupLanguage.isEmptyLine(line)) {
setClosed(true);
return 0;
}
MediaWikiLanguage dialect = (MediaWikiLanguage) getMarkupLanguage();
// paragraphs can have nested lists and other things
for (Block block : dialect.getParagraphBreakingBlocks()) {
if (block.canStart(line, offset)) {
setClosed(true);
return offset;
}
}
nestedStartOffset = calculateNestedStartOffset(line, offset);
if (nestedStartOffset != -1) {
nestedLineNumber = getState().getLineNumber();
}
++blockLineCount;
if (testPreformattedBlocks && offset == 0 && line.length() > 0 && line.charAt(0) == ' ') {
// a preformatted block.
setClosed(true);
return 0;
}
if (blockLineCount != 1 && nestedStartOffset == -1 && lastLineNumber != getState().getLineNumber()) {
// note: normally newlines don't automatically convert to line breaks
if (newlinesCauseLineBreak) {
builder.lineBreak();
} else {
// $NON-NLS-1$
builder.characters("\n");
}
}
if (nestedStartOffset > 0) {
line = line.substring(0, nestedStartOffset);
}
if (nestedStartOffset != offset) {
dialect.emitMarkupLine(getParser(), state, line, offset);
}
lastLineNumber = getState().getLineNumber();
return nestedStartOffset;
}
use of org.eclipse.mylyn.wikitext.mediawiki.MediaWikiLanguage in project mylyn.docs by eclipse.
the class OutlineParserTest method testHeadersWithHtmlTags.
public void testHeadersWithHtmlTags() {
// bug 374019
outlineParser = new OutlineParser(new MediaWikiLanguage());
OutlineItem outline = outlineParser.parse("= <span style=\"font-family:monospace\">Heading Text</span> =\n\n text");
assertEquals(1, outline.getChildren().size());
OutlineItem headingItem = outline.getChildren().get(0);
assertEquals("Heading_Text", headingItem.getId());
assertEquals("Heading Text", headingItem.getLabel());
}
use of org.eclipse.mylyn.wikitext.mediawiki.MediaWikiLanguage in project mylyn.docs by eclipse.
the class DitaTopicDocumentBuilderTest method testImageWithCaption.
public void testImageWithCaption() {
parser.setMarkupLanguage(new MediaWikiLanguage());
parser.parse("[[Image:images/editor-assist-proposals.png|alt=Alternative text|Caption text.]]");
String dita = out.toString();
assertTrue(Pattern.compile("<fig>\\s*<title>Caption text.</title>\\s*<image href=\"images/editor-assist-proposals.png\" alt=\"Alternative text\"/>\\s*</fig>", Pattern.DOTALL).matcher(dita).find());
}
Aggregations