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 -1;
}
++blockLineCount;
TracWikiLanguage markupLanguage = (TracWikiLanguage) getMarkupLanguage();
// paragraphs can have nested lists and other things
for (Block block : markupLanguage.getParagraphBreakingBlocks()) {
if (block.canStart(line, offset)) {
setClosed(true);
return 0;
}
}
if (blockLineCount != 1) {
// note: newlines don't automatically convert to line breaks
// $NON-NLS-1$
builder.characters("\n");
}
markupLanguage.emitMarkupLine(getParser(), state, line, offset);
return -1;
}
use of org.eclipse.mylyn.wikitext.parser.markup.Block in project mylyn.docs by eclipse.
the class ExtendedQuoteBlock method handleBlockContent.
@Override
protected void handleBlockContent(String content) {
if (nestedBlock == null) {
ConfluenceLanguage markupLanguage = (ConfluenceLanguage) getMarkupLanguage();
for (Block block : markupLanguage.getNestedBlocks()) {
if (block.canStart(content, 0)) {
nestedBlock = block.clone();
nestedBlock.setParser(getParser());
nestedBlock.setState(getState());
if (paraOpen) {
// para
builder.endBlock();
paraOpen = false;
paraLine = 0;
}
break;
}
}
}
if (nestedBlock != null) {
int lineOffset = nestedBlock.processLine(content, 0);
if (nestedBlock.isClosed()) {
nestedBlock = null;
}
if (lineOffset < content.length() && lineOffset >= 0) {
if (nestedBlock != null) {
// $NON-NLS-1$
throw new IllegalStateException("if a block does not fully process a line then it must be closed");
}
content = content.substring(lineOffset);
} else {
return;
}
}
if (blockLineCount == 1 && content.length() == 0) {
return;
}
if (blockLineCount > 1 && paraOpen && getMarkupLanguage().isEmptyLine(content)) {
// para
builder.endBlock();
paraOpen = false;
paraLine = 0;
return;
}
if (!paraOpen) {
builder.beginBlock(BlockType.PARAGRAPH, new Attributes());
paraOpen = true;
}
if (paraLine != 0) {
builder.lineBreak();
}
++paraLine;
getMarkupLanguage().emitMarkupLine(getParser(), state, content, 0);
}
use of org.eclipse.mylyn.wikitext.parser.markup.Block in project mylyn.docs by eclipse.
the class QuoteBlock method clone.
private Block clone(Block block) {
Block clonedBlock = block.clone();
clonedBlock.setParser(getParser());
clonedBlock.setState(getState());
return clonedBlock;
}
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.substring(offset))) {
setClosed(true);
return offset;
}
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 ParagraphBlock method processLineContent.
@Override
public int processLineContent(String line, int offset) {
if (blockLineCount == 0) {
builder.beginBlock(BlockType.PARAGRAPH, new Attributes());
}
if (markupLanguage.isEmptyLine(line)) {
setClosed(true);
return 0;
}
CreoleLanguage markupLanguage = (CreoleLanguage) getMarkupLanguage();
// paragraphs can have nested lists and other things
for (Block block : markupLanguage.getParagraphBreakingBlocks()) {
if (block.canStart(line, offset)) {
setClosed(true);
return 0;
}
}
if (blockLineCount > 0) {
// $NON-NLS-1$
builder.characters("\n");
}
++blockLineCount;
markupLanguage.emitMarkupLine(getParser(), state, line, offset);
return -1;
}
Aggregations