use of org.eclipse.mylyn.wikitext.parser.MarkupParser in project mylyn.docs by eclipse.
the class AsciiDocLanguageWithConfigurationIntegrationTest method parseWithCommonMarkupLanguageConfiguration.
@Test
public void parseWithCommonMarkupLanguageConfiguration() {
MarkupLanguageConfiguration configuration = new MarkupLanguageConfiguration();
MarkupParser parser = createParserWithConfiguration(configuration);
String html = parseAsciiDocToHtml(AsciiDocLanguageAttributeTest.MARKUP_FOR_DEFAULT, parser);
AsciiDocLanguageAttributeTest.ensureDefaultValues(html);
}
use of org.eclipse.mylyn.wikitext.parser.MarkupParser in project mylyn.docs by eclipse.
the class HtmlLanguageIntegrationTest method defaultMarkupLanguageHasImageSupport.
@Test
public void defaultMarkupLanguageHasImageSupport() {
MarkupLanguage sourceLanguage = getDefaultMarkupLanguage("Source HTML");
MarkupLanguage targetLanguage = getDefaultMarkupLanguage("Target HTML");
StringWriter stringWriter = new StringWriter();
MarkupParser markupParser = getMarkupParser(sourceLanguage, targetLanguage, stringWriter);
markupParser.parse("Text Before Image<img src=\"/favicon.ico\"/>Text After Image", false);
assertEquals("Text Before Image<img border=\"0\" src=\"/favicon.ico\"/>Text After Image", stringWriter.toString());
}
use of org.eclipse.mylyn.wikitext.parser.MarkupParser in project mylyn.docs by eclipse.
the class MarkupToEclipseHelpMojo method processMarkup.
protected void processMarkup(File sourceFile, String relativePath, MarkupLanguage markupLanguage) {
getLog().info(format("Processing markup file: {0}", sourceFile));
String name = sourceFile.getName();
if (name.lastIndexOf('.') != -1) {
name = name.substring(0, name.lastIndexOf('.'));
}
File htmlOutputFile = computeHtmlFile(relativePath, name);
if (!htmlOutputFile.exists() || htmlOutputFile.lastModified() < sourceFile.lastModified()) {
String markupContent = readFully(sourceFile);
if (!htmlOutputFile.getParentFile().exists()) {
if (!htmlOutputFile.getParentFile().mkdirs()) {
throw new BuildFailureException(format("Cannot create folder {0}", htmlOutputFile.getParentFile()));
}
}
Writer writer = createWriter(htmlOutputFile);
try {
HtmlDocumentBuilder builder = createRootBuilder(writer, name, relativePath);
SplittingStrategy splittingStrategy = createSplittingStrategy();
SplittingOutlineParser outlineParser = createOutlineParser(markupLanguage, splittingStrategy);
SplitOutlineItem rootTocItem = outlineParser.parse(markupContent);
rootTocItem.setSplitTarget(htmlOutputFile.getName());
SplittingHtmlDocumentBuilder splittingBuilder = createSplittingBuilder(builder, rootTocItem, htmlOutputFile, relativePath);
MarkupParser parser = new MarkupParser();
parser.setMarkupLanguage(markupLanguage);
parser.setBuilder(splittingBuilder);
parser.parse(markupContent);
createEclipseHelpToc(rootTocItem, sourceFile, relativePath, htmlOutputFile, name);
} finally {
close(writer, htmlOutputFile);
}
}
}
use of org.eclipse.mylyn.wikitext.parser.MarkupParser in project mylyn.docs by eclipse.
the class CreoleLanguageTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
parser = new MarkupParser(new CreoleLanguage());
}
use of org.eclipse.mylyn.wikitext.parser.MarkupParser in project mylyn.docs by eclipse.
the class LinkDefinitionValidationRule method findProblems.
@Override
public List<ValidationProblem> findProblems(String markup, int offset, int length) {
MarkupParser parser = new MarkupParser(new MarkdownLanguage());
MarkdownContentStateDocumentBuilder builder = new MarkdownContentStateDocumentBuilder();
parser.setBuilder(builder);
parser.parse(markup);
MarkdownContentState markdownContentState = builder.markdownContentState;
LinkDefinitionUsageTracker linkDefinitionUsageTracker = markdownContentState.getLinkDefinitionUsageTracker();
List<ValidationProblem> problems = new ArrayList<ValidationProblem>();
List<Position> missingLinkDefinitionPositions = linkDefinitionUsageTracker.getMissingLinkDefinitionPositions();
for (Position position : missingLinkDefinitionPositions) {
problems.add(new ValidationProblem(Severity.ERROR, MessageFormat.format(// $NON-NLS-1$
Messages.getString("LinkDefinitionValidationRule.missing"), position.getId()), position.getOffset(), position.getLength()));
}
List<Position> unusedLinkDefinitionPositions = linkDefinitionUsageTracker.getUnusedLinkDefinitionPositions();
for (Position position : unusedLinkDefinitionPositions) {
problems.add(new ValidationProblem(Severity.WARNING, MessageFormat.format(// $NON-NLS-1$
Messages.getString("LinkDefinitionValidationRule.unused"), position.getId()), position.getOffset(), position.getLength()));
}
return problems;
}
Aggregations