Search in sources :

Example 16 with Line

use of org.eclipse.mylyn.wikitext.commonmark.internal.Line in project mylyn.docs by eclipse.

the class InlineTest method create.

@Test
public void create() {
    Line line = new Line(3, 5, "text");
    Inline inline = new Inline(line, 8, 3) {

        @Override
        public void emit(DocumentBuilder builder) {
        }
    };
    assertSame(line, inline.getLine());
    assertEquals(8, inline.getOffset());
    assertEquals(3, inline.getLength());
    Locator locator = inline.getLocator();
    assertEquals(3, locator.getLineCharacterOffset());
    assertEquals(6, locator.getLineSegmentEndOffset());
    assertEquals(8, locator.getDocumentOffset());
    assertEquals(line.getOffset(), locator.getLineDocumentOffset());
    assertEquals(line.getText().length(), locator.getLineLength());
    assertEquals(line.getLineNumber() + 1, locator.getLineNumber());
}
Also used : Line(org.eclipse.mylyn.wikitext.commonmark.internal.Line) Locator(org.eclipse.mylyn.wikitext.parser.Locator) DocumentBuilder(org.eclipse.mylyn.wikitext.parser.DocumentBuilder) Test(org.junit.Test)

Example 17 with Line

use of org.eclipse.mylyn.wikitext.commonmark.internal.Line in project mylyn.docs by eclipse.

the class InlineTest method createContext.

@Test
public void createContext() {
    ProcessingContextBuilder builder = ProcessingContext.builder();
    new Inline(new Line(1, 2, "text"), 0, 1) {

        @Override
        public void emit(DocumentBuilder builder) {
        }
    }.createContext(builder);
    ProcessingContext context = builder.build();
    assertTrue(context.isEmpty());
}
Also used : Line(org.eclipse.mylyn.wikitext.commonmark.internal.Line) ProcessingContext(org.eclipse.mylyn.wikitext.commonmark.internal.ProcessingContext) DocumentBuilder(org.eclipse.mylyn.wikitext.parser.DocumentBuilder) ProcessingContextBuilder(org.eclipse.mylyn.wikitext.commonmark.internal.ProcessingContextBuilder) Test(org.junit.Test)

Example 18 with Line

use of org.eclipse.mylyn.wikitext.commonmark.internal.Line in project mylyn.docs by eclipse.

the class InlineParserTest method toStringContent.

@Test
public void toStringContent() {
    InlineParser parser = new InlineParser(new CodeSpan(), new AllCharactersSpan());
    String stringContent = parser.toStringContent(ProcessingContext.builder().build(), new TextSegment(Collections.singletonList(new Line(1, 0, "one `two` three"))));
    assertEquals("one two three", stringContent);
}
Also used : Line(org.eclipse.mylyn.wikitext.commonmark.internal.Line) TextSegment(org.eclipse.mylyn.wikitext.commonmark.internal.TextSegment) Test(org.junit.Test)

Example 19 with Line

use of org.eclipse.mylyn.wikitext.commonmark.internal.Line in project mylyn.docs by eclipse.

the class HtmlBlockTest method canStartDoesNotAdvanceLineSequencePosition.

@Test
public void canStartDoesNotAdvanceLineSequencePosition() {
    LineSequence lineSequence = LineSequence.create("<p\n  a=\"b\"\n>");
    Line firstLine = lineSequence.getCurrentLine();
    assertTrue(block.canStart(lineSequence));
    assertSame(firstLine, lineSequence.getCurrentLine());
}
Also used : Line(org.eclipse.mylyn.wikitext.commonmark.internal.Line) LineSequence(org.eclipse.mylyn.wikitext.commonmark.internal.LineSequence) Test(org.junit.Test)

Aggregations

Line (org.eclipse.mylyn.wikitext.commonmark.internal.Line)19 Matcher (java.util.regex.Matcher)7 TextSegment (org.eclipse.mylyn.wikitext.commonmark.internal.TextSegment)7 Test (org.junit.Test)5 InlineParser (org.eclipse.mylyn.wikitext.commonmark.internal.inlines.InlineParser)3 LineSequence (org.eclipse.mylyn.wikitext.commonmark.internal.LineSequence)2 Attributes (org.eclipse.mylyn.wikitext.parser.Attributes)2 DocumentBuilder (org.eclipse.mylyn.wikitext.parser.DocumentBuilder)2 HeadingAttributes (org.eclipse.mylyn.wikitext.parser.HeadingAttributes)2 StringWriter (java.io.StringWriter)1 Pattern (java.util.regex.Pattern)1 ProcessingContext (org.eclipse.mylyn.wikitext.commonmark.internal.ProcessingContext)1 ProcessingContextBuilder (org.eclipse.mylyn.wikitext.commonmark.internal.ProcessingContextBuilder)1 SimplifiedHtmlDocumentBuilder (org.eclipse.mylyn.wikitext.commonmark.internal.spec.SimplifiedHtmlDocumentBuilder)1 Locator (org.eclipse.mylyn.wikitext.parser.Locator)1 HtmlDocumentBuilder (org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder)1