use of org.eclipse.mylyn.wikitext.commonmark.internal.TextSegment in project mylyn.docs by eclipse.
the class SetextHeaderBlock method process.
@Override
public void process(ProcessingContext context, DocumentBuilder builder, LineSequence lineSequence) {
Line currentLine = lineSequence.getCurrentLine();
Line nextLine = lineSequence.getNextLine();
Matcher matcher = setextUnderlinePattern.matcher(nextLine.getText());
checkState(matcher.matches());
lineSequence.advance();
builder.setLocator(currentLine.toLocator());
int headingLevel = headingLevel(matcher);
TextSegment textSegment = new TextSegment(Collections.singletonList(currentLine));
HeadingAttributes attributes = new HeadingAttributes();
InlineParser inlineParser = context.getInlineParser();
String headingText = inlineParser.toStringContent(context, textSegment);
attributes.setId(context.generateHeadingId(headingLevel, headingText));
builder.beginHeading(headingLevel, attributes);
inlineParser.emit(context, builder, textSegment);
builder.endHeading();
lineSequence.advance();
}
use of org.eclipse.mylyn.wikitext.commonmark.internal.TextSegment in project mylyn.docs by eclipse.
the class ParagraphBlock method createContext.
@Override
public void createContext(ProcessingContextBuilder contextBuilder, LineSequence lineSequence) {
TextSegment textSegment = extractTextSegment(lineSequence);
contextBuilder.getInlineParser().createContext(contextBuilder, textSegment);
}
use of org.eclipse.mylyn.wikitext.commonmark.internal.TextSegment in project mylyn.docs by eclipse.
the class PotentialEmphasisSpanTest method createCursor.
private Cursor createCursor(String markup, int offset) {
TextSegment segment = new TextSegment(ImmutableList.of(new Line(1, 0, markup)));
Cursor cursor = new Cursor(segment);
cursor.advance(offset);
return cursor;
}
use of org.eclipse.mylyn.wikitext.commonmark.internal.TextSegment in project mylyn.docs by eclipse.
the class CursorTest method toCursorOffset.
@Test
public void toCursorOffset() {
Cursor cursor = new Cursor(new TextSegment(ImmutableList.of(new Line(1, 10, "abc"))));
assertEquals(0, cursor.toCursorOffset(10));
assertEquals(2, cursor.toCursorOffset(12));
thrown.expect(IllegalArgumentException.class);
cursor.toCursorOffset(9);
}
use of org.eclipse.mylyn.wikitext.commonmark.internal.TextSegment in project mylyn.docs by eclipse.
the class FencedCodeBlock method addInfoTextCssClass.
private void addInfoTextCssClass(ProcessingContext processingContext, Attributes codeAttributes, Matcher matcher) {
String infoText = matcher.group(3);
if (infoText != null && !infoText.isEmpty()) {
InlineParser inlineParser = processingContext.getInlineParser();
String language = inlineParser.toStringContent(processingContext, new TextSegment(Collections.singletonList(new Line(0, 0, infoText))));
codeAttributes.setCssClass("language-" + language);
}
}
Aggregations