Search in sources :

Example 6 with 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) {
    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;
}
Also used : Attributes(org.eclipse.mylyn.wikitext.parser.Attributes) Block(org.eclipse.mylyn.wikitext.parser.markup.Block) TracWikiLanguage(org.eclipse.mylyn.wikitext.tracwiki.TracWikiLanguage)

Example 7 with Block

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);
}
Also used : ConfluenceLanguage(org.eclipse.mylyn.wikitext.confluence.ConfluenceLanguage) Attributes(org.eclipse.mylyn.wikitext.parser.Attributes) Block(org.eclipse.mylyn.wikitext.parser.markup.Block)

Example 8 with Block

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;
}
Also used : Block(org.eclipse.mylyn.wikitext.parser.markup.Block)

Example 9 with Block

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;
}
Also used : Attributes(org.eclipse.mylyn.wikitext.parser.Attributes) Block(org.eclipse.mylyn.wikitext.parser.markup.Block)

Example 10 with 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) {
    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;
}
Also used : CreoleLanguage(org.eclipse.mylyn.wikitext.creole.CreoleLanguage) Attributes(org.eclipse.mylyn.wikitext.parser.Attributes) Block(org.eclipse.mylyn.wikitext.parser.markup.Block)

Aggregations

Block (org.eclipse.mylyn.wikitext.parser.markup.Block)11 Attributes (org.eclipse.mylyn.wikitext.parser.Attributes)8 Matcher (java.util.regex.Matcher)1 ConfluenceLanguage (org.eclipse.mylyn.wikitext.confluence.ConfluenceLanguage)1 CreoleLanguage (org.eclipse.mylyn.wikitext.creole.CreoleLanguage)1 MediaWikiLanguage (org.eclipse.mylyn.wikitext.mediawiki.MediaWikiLanguage)1 BehaviorSwitchBlock (org.eclipse.mylyn.wikitext.mediawiki.internal.block.BehaviorSwitchBlock)1 CommentBlock (org.eclipse.mylyn.wikitext.mediawiki.internal.block.CommentBlock)1 EscapeBlock (org.eclipse.mylyn.wikitext.mediawiki.internal.block.EscapeBlock)1 HeadingBlock (org.eclipse.mylyn.wikitext.mediawiki.internal.block.HeadingBlock)1 ListBlock (org.eclipse.mylyn.wikitext.mediawiki.internal.block.ListBlock)1 ParagraphBlock (org.eclipse.mylyn.wikitext.mediawiki.internal.block.ParagraphBlock)1 PreformattedBlock (org.eclipse.mylyn.wikitext.mediawiki.internal.block.PreformattedBlock)1 SourceBlock (org.eclipse.mylyn.wikitext.mediawiki.internal.block.SourceBlock)1 TableBlock (org.eclipse.mylyn.wikitext.mediawiki.internal.block.TableBlock)1 TableOfContentsBlock (org.eclipse.mylyn.wikitext.mediawiki.internal.block.TableOfContentsBlock)1 AbstractMarkupLanguage (org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage)1 TextileLanguage (org.eclipse.mylyn.wikitext.textile.TextileLanguage)1 TracWikiLanguage (org.eclipse.mylyn.wikitext.tracwiki.TracWikiLanguage)1 TWikiLanguage (org.eclipse.mylyn.wikitext.twiki.TWikiLanguage)1