Search in sources :

Example 1 with TextBlock

use of us.parr.bookish.model.TextBlock in project bookish by parrt.

the class Translator method visitCitation.

@Override
public OutputModelObject visitCitation(BookishParser.CitationContext ctx) {
    String label = null;
    EntityDef def = null;
    if (ctx.REF() != null) {
        label = stripQuotes(ctx.REF().getText());
        def = document.getEntity(label);
        if (def == null) {
            System.err.printf("line %d: Unknown label '%s'\n", ctx.start.getLine(), label);
            return null;
        }
    }
    def.model = new Citation(def, label, (TextBlock) visit(ctx.t), (TextBlock) visit(ctx.a));
    return null;
}
Also used : Citation(us.parr.bookish.model.Citation) TextBlock(us.parr.bookish.model.TextBlock) EntityDef(us.parr.bookish.model.entity.EntityDef)

Example 2 with TextBlock

use of us.parr.bookish.model.TextBlock in project bookish by parrt.

the class Translator method visitSidefig.

// figure    : FIGURE attrs END_OF_TAG paragraph_content END_FIGURE
@Override
public OutputModelObject visitSidefig(BookishParser.SidefigContext ctx) {
    String label = ctx.attrs.attrMap.get("label");
    EntityDef def = null;
    if (label != null) {
        def = document.getEntity(label);
        if (def == null) {
            System.err.printf("line %d: Unknown label '%s'\n", ctx.start.getLine(), label);
            return null;
        }
    }
    Paragraph p = (Paragraph) visit(ctx.paragraph_content());
    TextBlock figText = new TextBlock(p.elements);
    SideFigure f = new SideFigure(def, label, figText, ctx.attrs.attrMap);
    if (def != null) {
        def.model = f;
    }
    // a ref will make this appear
    return null;
}
Also used : SideFigure(us.parr.bookish.model.SideFigure) TextBlock(us.parr.bookish.model.TextBlock) EntityDef(us.parr.bookish.model.entity.EntityDef) Paragraph(us.parr.bookish.model.Paragraph)

Example 3 with TextBlock

use of us.parr.bookish.model.TextBlock in project bookish by parrt.

the class Translator method visitAside.

@Override
public OutputModelObject visitAside(BookishParser.AsideContext ctx) {
    Join content = (Join) visit(ctx.section_content());
    TextBlock text = new TextBlock(content.elements);
    return new Aside(text, ctx.attrs().attrMap);
}
Also used : Aside(us.parr.bookish.model.Aside) Join(us.parr.bookish.model.Join) TextBlock(us.parr.bookish.model.TextBlock)

Aggregations

TextBlock (us.parr.bookish.model.TextBlock)3 EntityDef (us.parr.bookish.model.entity.EntityDef)2 Aside (us.parr.bookish.model.Aside)1 Citation (us.parr.bookish.model.Citation)1 Join (us.parr.bookish.model.Join)1 Paragraph (us.parr.bookish.model.Paragraph)1 SideFigure (us.parr.bookish.model.SideFigure)1