use of org.eclipse.mylyn.wikitext.parser.HeadingAttributes in project mylyn.docs by eclipse.
the class UnderlinedHeadingBlock method processLineContent.
@Override
public int processLineContent(String line, int offset) {
if (blockLineCount == 0) {
HeadingAttributes attributes = new HeadingAttributes();
attributes.setId(state.getIdGenerator().newId(null, line));
int level = LanguageSupport.computeHeadingLevel(lineLevel, getAsciiDocState());
builder.beginHeading(level, attributes);
builder.characters(line.trim());
} else {
builder.endHeading();
setClosed(true);
}
blockLineCount++;
return -1;
}
use of org.eclipse.mylyn.wikitext.parser.HeadingAttributes in project mylyn.docs by eclipse.
the class HeadingBlock method emitHeading.
private void emitHeading(int level) {
String text = matcher.group(2);
String closingGroup = matcher.group(4);
HeadingAttributes attributes = new HeadingAttributes();
if (level == 1) {
attributes.setId("header");
} else {
attributes.setId(state.getIdGenerator().newId(null, text));
}
builder.beginHeading(level, attributes);
getMarkupLanguage().emitMarkupLine(getParser(), state, matcher.start(2), text, 0);
if (closingGroup.length() > 0 && closingGroup.length() != level) {
builder.characters(matcher.group(3));
builder.characters(closingGroup);
}
builder.endHeading();
}
use of org.eclipse.mylyn.wikitext.parser.HeadingAttributes 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.parser.HeadingAttributes in project mylyn.docs by eclipse.
the class HeadingBlock method processLineContent.
@Override
public int processLineContent(String line, int offset) {
offset = matcher.start(3);
int level = matcher.group(1).length();
String bangEscape = matcher.group(2);
boolean omitFromToc = false;
if (bangEscape != null && bangEscape.length() > 0) {
omitFromToc = true;
}
if (offset > 0 && level > 0) {
HeadingAttributes attributes = new HeadingAttributes();
attributes.setOmitFromTableOfContents(omitFromToc);
// $NON-NLS-1$
attributes.setId(state.getIdGenerator().newId("h" + level, line.substring(offset)));
builder.beginHeading(level, attributes);
builder.characters(line.substring(offset).trim());
builder.endHeading();
}
setClosed(true);
return -1;
}
use of org.eclipse.mylyn.wikitext.parser.HeadingAttributes 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