Search in sources :

Example 41 with MarkupLanguage

use of org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage in project mylyn.docs by eclipse.

the class HtmlLanguageIntegrationTest method emitImageWithoutImageSupport.

@Test
public void emitImageWithoutImageSupport() {
    MarkupLanguage sourceLanguage = getDefaultMarkupLanguage("Source HTML");
    MarkupLanguage targetLanguageWithNoImageSupport = getMarkupLanguageWithoutImageSupport("Target HTML With No Images");
    StringWriter stringWriter = new StringWriter();
    MarkupParser markupParser = getMarkupParser(sourceLanguage, targetLanguageWithNoImageSupport, stringWriter);
    markupParser.parse("Text Before Image<img src=\"/favicon.ico\"/>Text After Image", false);
    assertEquals("Text Before ImageText After Image", stringWriter.toString());
}
Also used : StringWriter(java.io.StringWriter) MarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage) MarkupParser(org.eclipse.mylyn.wikitext.parser.MarkupParser) Test(org.junit.Test)

Example 42 with MarkupLanguage

use of org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage in project mylyn.docs by eclipse.

the class ConfluenceLanguageTest method testDiscoverable.

@Test
public void testDiscoverable() {
    MarkupLanguage language = ServiceLocator.getInstance().getMarkupLanguage("Confluence");
    assertNotNull(language);
    assertTrue(language instanceof ConfluenceLanguage);
}
Also used : MarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage) Test(org.junit.Test) AbstractMarkupGenerationTest(org.eclipse.mylyn.wikitext.toolkit.AbstractMarkupGenerationTest)

Example 43 with MarkupLanguage

use of org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage in project mylyn.docs by eclipse.

the class FileToMarkupLanguageTest method mockMarkupLanguage.

private MarkupLanguage mockMarkupLanguage(String name) {
    MarkupLanguage mock = mock(MarkupLanguage.class);
    doReturn(name).when(mock).getName();
    doReturn(Sets.newHashSet(name)).when(mock).getFileExtensions();
    return mock;
}
Also used : FileToMarkupLanguage(org.eclipse.mylyn.wikitext.maven.internal.FileToMarkupLanguage) MarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage)

Example 44 with MarkupLanguage

use of org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage in project mylyn.docs by eclipse.

the class WikiTextTest method getMarkupLanguageForFilenameCopied.

@Test
public void getMarkupLanguageForFilenameCopied() {
    MarkupLanguage markupLanguage = WikiText.getMarkupLanguageForFilename("test.textile");
    assertNotSame(markupLanguage, WikiText.getMarkupLanguageForFilename("test.textile"));
}
Also used : MarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage) Test(org.junit.Test)

Example 45 with MarkupLanguage

use of org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage in project mylyn.docs by eclipse.

the class WikiMarkupGenerationContribution method getContributionItems.

@Override
protected IContributionItem[] getContributionItems() {
    Map<String, IContributionItem> items = new TreeMap<>();
    for (MarkupLanguage markupLanguage : ServiceLocator.getInstance().getAllMarkupLanguages()) {
        try {
            // test to see if markup generation is supported
            markupLanguage.createDocumentBuilder(new StringWriter());
        } catch (UnsupportedOperationException e) {
            // markup langage doesn't provide document builder
            continue;
        }
        String commandId = ConvertMarkupToMarkup.COMMAND_ID;
        // $NON-NLS-1$ //$NON-NLS-2$
        String id = commandId + '.' + markupLanguage.getName().replaceAll("\\W", "_");
        HashMap<String, String> args = new HashMap<>();
        args.put(ConvertMarkupToMarkup.PARAM_MARKUP_LANGUAGE, markupLanguage.getName());
        CommandContributionItemParameter parameters = new CommandContributionItemParameter(serviceLocator, id, commandId, CommandContributionItem.STYLE_PUSH);
        parameters.label = NLS.bind(Messages.WikiMarkupGenerationContribution_generate_markup, markupLanguage.getName());
        parameters.parameters = args;
        items.put(markupLanguage.getName(), new CommandContributionItem(parameters));
    }
    return items.values().toArray(new IContributionItem[items.size()]);
}
Also used : StringWriter(java.io.StringWriter) HashMap(java.util.HashMap) IContributionItem(org.eclipse.jface.action.IContributionItem) CommandContributionItemParameter(org.eclipse.ui.menus.CommandContributionItemParameter) MarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage) TreeMap(java.util.TreeMap) CommandContributionItem(org.eclipse.ui.menus.CommandContributionItem)

Aggregations

MarkupLanguage (org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage)60 Test (org.junit.Test)18 AbstractMarkupLanguage (org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage)15 MarkupParser (org.eclipse.mylyn.wikitext.parser.MarkupParser)8 File (java.io.File)7 BuildException (org.apache.tools.ant.BuildException)7 CoreException (org.eclipse.core.runtime.CoreException)7 MockMarkupLanguage (org.eclipse.mylyn.internal.wikitext.MockMarkupLanguage)7 StringWriter (java.io.StringWriter)6 HashMap (java.util.HashMap)5 DirectoryScanner (org.apache.tools.ant.DirectoryScanner)5 FileSet (org.apache.tools.ant.types.FileSet)5 OutlineItem (org.eclipse.mylyn.wikitext.parser.outline.OutlineItem)5 Point (org.eclipse.swt.graphics.Point)5 IOException (java.io.IOException)4 IFile (org.eclipse.core.resources.IFile)4 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)4 TreeMap (java.util.TreeMap)3 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3