Search in sources :

Example 6 with LinkAttributes

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

the class HtmlDocumentBuilder2Test method testHtmlBeginSpanWithId.

public void testHtmlBeginSpanWithId() {
    // Bug 492302
    LinkAttributes attributes = new LinkAttributes();
    attributes.setId("lorem");
    builder.beginSpan(SpanType.LINK, attributes);
    builder.endSpan();
    assertContainsPattern("<a id=\"lorem\"></a>");
}
Also used : LinkAttributes(org.eclipse.mylyn.wikitext.parser.LinkAttributes)

Example 7 with LinkAttributes

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

the class TextileDocumentBuilder method computeSpan.

@Override
protected Block computeSpan(SpanType type, Attributes attributes) {
    String appendStyle = null;
    switch(type) {
        case UNDERLINED:
            // $NON-NLS-1$
            appendStyle = "text-decoration:underline;";
            break;
        case MONOSPACE:
            // $NON-NLS-1$
            appendStyle = "font-family:monospace;";
            break;
    }
    if (appendStyle != null) {
        attributes = new Attributes(attributes.getId(), attributes.getCssClass(), attributes.getCssStyle(), attributes.getLanguage());
        attributes.appendCssStyle(appendStyle);
    }
    Block block;
    String spanAttributes = computeAttributes(attributes);
    switch(type) {
        case BOLD:
            // $NON-NLS-1$//$NON-NLS-2$
            block = new ContentBlock("**" + spanAttributes, "**", true, false, 0, 0);
            break;
        case CITATION:
            // $NON-NLS-1$//$NON-NLS-2$
            block = new ContentBlock("??" + spanAttributes, "??", true, false, 0, 0);
            break;
        case DELETED:
            // $NON-NLS-1$//$NON-NLS-2$
            block = new ContentBlock("-" + spanAttributes, "-", true, false, 0, 0);
            break;
        case MARK:
        case EMPHASIS:
            // $NON-NLS-1$//$NON-NLS-2$
            block = new ContentBlock("_" + spanAttributes, "_", true, false, 0, 0);
            break;
        case INSERTED:
            // $NON-NLS-1$//$NON-NLS-2$
            block = new ContentBlock("+" + spanAttributes, "+", true, false, 0, 0);
            break;
        case CODE:
            // $NON-NLS-1$//$NON-NLS-2$
            block = new ContentBlock("@" + spanAttributes, "@", true, false, 0, 0);
            break;
        case ITALIC:
            // $NON-NLS-1$//$NON-NLS-2$
            block = new ContentBlock("__" + spanAttributes, "__", true, false, 0, 0);
            break;
        case LINK:
            if (attributes instanceof LinkAttributes) {
                block = new LinkBlock((LinkAttributes) attributes);
            } else {
                block = new SpanBlock(spanAttributes, true, false);
            }
            break;
        case MONOSPACE:
            block = new SpanBlock(spanAttributes, true, false);
            break;
        case STRONG:
            // $NON-NLS-1$//$NON-NLS-2$
            block = new ContentBlock("*" + spanAttributes, "*", true, false, 0, 0);
            break;
        case SUPERSCRIPT:
            // $NON-NLS-1$//$NON-NLS-2$
            block = new ContentBlock("^" + spanAttributes, "^", true, false, 0, 0);
            break;
        case SUBSCRIPT:
            // $NON-NLS-1$//$NON-NLS-2$
            block = new ContentBlock("~" + spanAttributes, "~", true, false, 0, 0);
            break;
        // case QUOTE: not supported by Textile
        case UNDERLINED:
        case SPAN:
        default:
            if (spanAttributes.length() == 0) {
                // $NON-NLS-1$
                block = new SpanBlock("", true, false);
            } else {
                block = new SpanBlock(spanAttributes, true, false);
            }
            break;
    }
    return block;
}
Also used : LinkAttributes(org.eclipse.mylyn.wikitext.parser.LinkAttributes) LinkAttributes(org.eclipse.mylyn.wikitext.parser.LinkAttributes) Attributes(org.eclipse.mylyn.wikitext.parser.Attributes)

Example 8 with LinkAttributes

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

the class MultiplexingDocumentBuilderTest method imageLink.

@Test
public void imageLink() {
    multiplexer.imageLink(new LinkAttributes(), new ImageAttributes(), "https://example.com", "http://example.com/foo.png");
    assertEvents(new ImageLinkEvent(new LinkAttributes(), new ImageAttributes(), "https://example.com", "http://example.com/foo.png"));
}
Also used : LinkAttributes(org.eclipse.mylyn.wikitext.parser.LinkAttributes) ImageAttributes(org.eclipse.mylyn.wikitext.parser.ImageAttributes) ImageLinkEvent(org.eclipse.mylyn.wikitext.parser.builder.event.ImageLinkEvent) Test(org.junit.Test)

Example 9 with LinkAttributes

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

the class MultiplexingDocumentBuilderTest method link.

@Test
public void link() {
    multiplexer.link(new LinkAttributes(), "https://example.com", "test");
    assertEvents(new LinkEvent(new LinkAttributes(), "https://example.com", "test"));
}
Also used : LinkAttributes(org.eclipse.mylyn.wikitext.parser.LinkAttributes) ImageLinkEvent(org.eclipse.mylyn.wikitext.parser.builder.event.ImageLinkEvent) LinkEvent(org.eclipse.mylyn.wikitext.parser.builder.event.LinkEvent) Test(org.junit.Test)

Example 10 with LinkAttributes

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

the class TextileDocumentBuilderTest method testLinkWithNullHref.

public void testLinkWithNullHref() {
    builder.beginDocument();
    builder.characters("a ");
    builder.link(new LinkAttributes(), null, "link text");
    builder.characters(" test");
    builder.endDocument();
    String markup = out.toString();
    assertEquals("a \"link text\": test\n\n", markup);
}
Also used : LinkAttributes(org.eclipse.mylyn.wikitext.parser.LinkAttributes)

Aggregations

LinkAttributes (org.eclipse.mylyn.wikitext.parser.LinkAttributes)45 Test (org.junit.Test)16 ImageAttributes (org.eclipse.mylyn.wikitext.parser.ImageAttributes)12 Attributes (org.eclipse.mylyn.wikitext.parser.Attributes)10 ImageLinkEvent (org.eclipse.mylyn.wikitext.parser.builder.event.ImageLinkEvent)5 TableAttributes (org.eclipse.mylyn.wikitext.parser.TableAttributes)2 LinkEvent (org.eclipse.mylyn.wikitext.parser.builder.event.LinkEvent)2 StringWriter (java.io.StringWriter)1 ArrayList (java.util.ArrayList)1 IContainer (org.eclipse.core.resources.IContainer)1 IFile (org.eclipse.core.resources.IFile)1 IResource (org.eclipse.core.resources.IResource)1 IPath (org.eclipse.core.runtime.IPath)1 BadLocationException (org.eclipse.jface.text.BadLocationException)1 IDocument (org.eclipse.jface.text.IDocument)1 IRegion (org.eclipse.jface.text.IRegion)1 Region (org.eclipse.jface.text.Region)1 IHyperlink (org.eclipse.jface.text.hyperlink.IHyperlink)1 ListAttributes (org.eclipse.mylyn.wikitext.parser.ListAttributes)1 MarkupParser (org.eclipse.mylyn.wikitext.parser.MarkupParser)1