Search in sources :

Example 1 with Block

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

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

Example 3 with Block

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);
    }
}
Also used : ListBlock(org.eclipse.mylyn.wikitext.mediawiki.internal.block.ListBlock) TableOfContentsBlock(org.eclipse.mylyn.wikitext.mediawiki.internal.block.TableOfContentsBlock) SourceBlock(org.eclipse.mylyn.wikitext.mediawiki.internal.block.SourceBlock) CommentBlock(org.eclipse.mylyn.wikitext.mediawiki.internal.block.CommentBlock) TableBlock(org.eclipse.mylyn.wikitext.mediawiki.internal.block.TableBlock) PreformattedBlock(org.eclipse.mylyn.wikitext.mediawiki.internal.block.PreformattedBlock) BehaviorSwitchBlock(org.eclipse.mylyn.wikitext.mediawiki.internal.block.BehaviorSwitchBlock) HeadingBlock(org.eclipse.mylyn.wikitext.mediawiki.internal.block.HeadingBlock) TableOfContentsBlock(org.eclipse.mylyn.wikitext.mediawiki.internal.block.TableOfContentsBlock) PreformattedBlock(org.eclipse.mylyn.wikitext.mediawiki.internal.block.PreformattedBlock) SourceBlock(org.eclipse.mylyn.wikitext.mediawiki.internal.block.SourceBlock) TableBlock(org.eclipse.mylyn.wikitext.mediawiki.internal.block.TableBlock) CommentBlock(org.eclipse.mylyn.wikitext.mediawiki.internal.block.CommentBlock) ParagraphBlock(org.eclipse.mylyn.wikitext.mediawiki.internal.block.ParagraphBlock) BehaviorSwitchBlock(org.eclipse.mylyn.wikitext.mediawiki.internal.block.BehaviorSwitchBlock) ListBlock(org.eclipse.mylyn.wikitext.mediawiki.internal.block.ListBlock) Block(org.eclipse.mylyn.wikitext.parser.markup.Block) EscapeBlock(org.eclipse.mylyn.wikitext.mediawiki.internal.block.EscapeBlock) ParagraphBlock(org.eclipse.mylyn.wikitext.mediawiki.internal.block.ParagraphBlock) HeadingBlock(org.eclipse.mylyn.wikitext.mediawiki.internal.block.HeadingBlock) EscapeBlock(org.eclipse.mylyn.wikitext.mediawiki.internal.block.EscapeBlock)

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

Example 5 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 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;
}
Also used : TWikiLanguage(org.eclipse.mylyn.wikitext.twiki.TWikiLanguage) 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