use of org.eclipse.mylyn.wikitext.parser.markup.Block in project mylyn.docs by eclipse.
the class ListBlock method findCloseOffset.
@Override
public int findCloseOffset(String line, int lineOffset) {
if (listContinuation) {
if (nestingBegin) {
AbstractMarkupLanguage language = (AbstractMarkupLanguage) getParser().getMarkupLanguage();
Block block = language.startBlock(line, lineOffset);
nestedBlockInterruptible = isInterruptibleNestedBlock(block);
nestingBegin = false;
}
if (nestedBlockInterruptible && (line.isEmpty() || isListContinuation(line))) {
listContinuation = isListContinuation(line);
return 0;
}
}
return -1;
}
use of org.eclipse.mylyn.wikitext.parser.markup.Block in project mylyn.docs by eclipse.
the class ParagraphBlock method processLineContent.
@Override
protected int processLineContent(String line, int offset) {
// start of block
if (blockLineCount == 0) {
builder.beginBlock(BlockType.PARAGRAPH, new Attributes());
}
// empty line: start new block
if (markupLanguage.isEmptyLine(line)) {
setClosed(true);
return 0;
}
for (Block block : markupLanguage.getParagraphBreakingBlocks()) {
if (block.canStart(line, offset)) {
setClosed(true);
return offset;
}
}
// next line, does not convert to line break
if (blockLineCount > 0) {
// $NON-NLS-1$
builder.characters("\n");
}
getMarkupLanguage().emitMarkupLine(getParser(), state, line, offset);
blockLineCount++;
return -1;
}
use of org.eclipse.mylyn.wikitext.parser.markup.Block in project mylyn.docs by eclipse.
the class MediaWikiLanguage method addStandardBlocks.
@Override
protected void addStandardBlocks(List<Block> blocks, List<Block> paragraphBreakingBlocks) {
// IMPORTANT NOTE: Most items below have order dependencies. DO NOT REORDER ITEMS BELOW!!
blocks.add(new HeadingBlock());
blocks.add(new ListBlock());
blocks.add(new TableBlock());
if (hasPreformattedBlock()) {
// preformatted blocks are lines that start with a single space, and thus are non-optimal for
// repository usage.
blocks.add(new PreformattedBlock());
}
blocks.add(new SourceBlock());
blocks.add(new TableOfContentsBlock());
blocks.add(new EscapeBlock());
blocks.add(new CommentBlock());
blocks.add(new BehaviorSwitchBlock());
for (Block block : blocks) {
if (block instanceof ParagraphBlock || block instanceof CommentBlock) {
continue;
}
paragraphBreakingBlocks.add(block);
}
}
use of org.eclipse.mylyn.wikitext.parser.markup.Block in project mylyn.docs by eclipse.
the class ParagraphBlock method processLineContent.
@Override
public int processLineContent(String line, int offset) {
nestedStartOffset = -1;
nestedLineNumber = -1;
if (blockLineCount == 0) {
Attributes attributes = new Attributes();
builder.beginBlock(BlockType.PARAGRAPH, attributes);
}
if (markupLanguage.isEmptyLine(line)) {
setClosed(true);
return 0;
}
MediaWikiLanguage dialect = (MediaWikiLanguage) getMarkupLanguage();
// paragraphs can have nested lists and other things
for (Block block : dialect.getParagraphBreakingBlocks()) {
if (block.canStart(line, offset)) {
setClosed(true);
return offset;
}
}
nestedStartOffset = calculateNestedStartOffset(line, offset);
if (nestedStartOffset != -1) {
nestedLineNumber = getState().getLineNumber();
}
++blockLineCount;
if (testPreformattedBlocks && offset == 0 && line.length() > 0 && line.charAt(0) == ' ') {
// a preformatted block.
setClosed(true);
return 0;
}
if (blockLineCount != 1 && nestedStartOffset == -1 && lastLineNumber != getState().getLineNumber()) {
// note: normally newlines don't automatically convert to line breaks
if (newlinesCauseLineBreak) {
builder.lineBreak();
} else {
// $NON-NLS-1$
builder.characters("\n");
}
}
if (nestedStartOffset > 0) {
line = line.substring(0, nestedStartOffset);
}
if (nestedStartOffset != offset) {
dialect.emitMarkupLine(getParser(), state, line, offset);
}
lastLineNumber = getState().getLineNumber();
return nestedStartOffset;
}
use of org.eclipse.mylyn.wikitext.parser.markup.Block in project mylyn.docs by eclipse.
the class ParagraphBlock method processLineContent.
@Override
public int processLineContent(String line, int offset) {
if (blockLineCount == 0) {
Attributes attributes = new Attributes();
builder.beginBlock(BlockType.PARAGRAPH, attributes);
}
if (markupLanguage.isEmptyLine(line)) {
setClosed(true);
return 0;
}
TWikiLanguage textileLanguage = (TWikiLanguage) getMarkupLanguage();
for (Block block : textileLanguage.getParagraphBreakingBlocks()) {
if (block.canStart(line, offset)) {
setClosed(true);
return 0;
}
}
if (blockLineCount != 0) {
builder.lineBreak();
}
++blockLineCount;
textileLanguage.emitMarkupLine(getParser(), state, line, offset);
return -1;
}
Aggregations