Esempio n. 1
0
  private Table pipeTable(Rover rover) {
    String head = rover.group("head");
    String widths = rover.group("widths");
    String rows = rover.group("rows");

    Table table = new Table(markdown);
    String[] splitted = rows.split("\n");

    table.columns(COLDEF_P, widths);

    if (head != null) table.addHead(pipeSplit(head));

    for (String row : splitted) table.addRow(pipeSplit(row));

    rover.next();
    return table;
  }
Esempio n. 2
0
  private Table fixedTable(Rover rover, String rowbreak) {

    String head = rover.group("head");
    String widths = rover.group("widths");
    String rows = rover.group("rows");

    Table table = new Table(markdown);

    String[] splitted = rows.split(rowbreak);
    if (splitted.length == 1) splitted = rows.split("\n");

    table.columns(COLDEF_P, widths);

    if (head != null) {
      table.addHead(head);
    }

    if (!widths.contains(":"))
      if (head != null) table.alignment(head);
      else table.alignment(splitted[0]);

    for (String row : splitted) {
      table.addRow(row);
    }
    rover.next();
    return table;
  }
Esempio n. 3
0
  @Override
  public Block process(Rover rover) throws Exception {
    if (rover.at(TABLE_EXT_P) || rover.at(CAPTION_P)) {
      String caption = rover.group("caption");
      rover.next();
      Table table = tables(rover);
      if (table != null) {
        table.setCaption(caption);
        return table;
      }
      rover.error("Table extension found but no table pattern matched");
    } else {
      Table table = tables(rover);
      if (table != null) {
        if (rover.at(CAPTION_P)) {
          table.setCaption(rover.group("caption"));
          rover.consume();
        }
        return table;
      }
    }

    return null;
  }