use of org.eclipse.mylyn.wikitext.commonmark.internal.inlines.InlineParser 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.inlines.InlineParser in project mylyn.docs by eclipse.
the class ProcessingContextTest method inlineParser.
@Test
public void inlineParser() {
InlineParser inlineParser = new InlineParser(ImmutableList.<SourceSpan>of());
ProcessingContext context = ProcessingContext.builder().inlineParser(inlineParser).build();
assertSame(inlineParser, context.getInlineParser());
assertNotNull(ProcessingContext.builder().build().getInlineParser());
}
use of org.eclipse.mylyn.wikitext.commonmark.internal.inlines.InlineParser in project mylyn.docs by eclipse.
the class InlineContent method markdown.
public static InlineParser markdown() {
ImmutableList.Builder<SourceSpan> spansBuilder = ImmutableList.builder();
addStandardSpans(spansBuilder);
spansBuilder.add(new AutoLinkWithoutDemarcationSpan());
addTerminatorSpans(spansBuilder);
return new InlineParser(spansBuilder.build());
}
use of org.eclipse.mylyn.wikitext.commonmark.internal.inlines.InlineParser 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);
}
}
use of org.eclipse.mylyn.wikitext.commonmark.internal.inlines.InlineParser in project mylyn.docs by eclipse.
the class AtxHeaderBlock method process.
@Override
public void process(ProcessingContext context, DocumentBuilder builder, LineSequence lineSequence) {
Line currentLine = lineSequence.getCurrentLine();
Matcher matcher = PATTERN.matcher(currentLine.getText());
checkState(matcher.matches());
lineSequence.advance();
builder.setLocator(currentLine.toLocator());
int contentOffset = matcher.start(2);
int contentEnd = matcher.end(2);
int headingLevel = headingLevel(matcher);
if (contentEnd > contentOffset) {
Line headerContent = currentLine.segment(contentOffset, contentEnd - contentOffset);
TextSegment textSegment = new TextSegment(Collections.singletonList(headerContent));
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();
} else {
builder.beginHeading(headingLevel, new HeadingAttributes());
builder.endHeading();
}
}
Aggregations