Package com.overzealous.remark.util

Examples of com.overzealous.remark.util.MarkdownTable


  private static final Pattern STYLE_ALIGNMENT_PATTERN =
        Pattern.compile("text-align:\\s*([a-z]+)", Pattern.CASE_INSENSITIVE);

  public void handleNode(NodeHandler parent, Element node, DocumentConverter converter) {
    MarkdownTable table = new MarkdownTable();

    // loop over every direct child of the table node.
    for(final Element child : node.children()) {

      if(child.tagName().equals("thead")) {
        // handle explicitly declared header sections
        for(final Element headerRow : child.children()) {
          processRow(table.addHeaderRow(), headerRow, converter);
        }

      } else if(child.tagName().equals("tbody") || child.tagName().equals("tfoot")) {
        // handle body or foot sections - note: there's no special handling for tfoot
        for(final Element bodyRow : child.children()) {
          processRow(table.addBodyRow(), bodyRow, converter);
        }

      } else if(child.tagName().equals("tr")) {
        // Hrm, a row was added outside a valid table body or header...
        if(!child.children().isEmpty()) {
          if(child.children().get(0).tagName().equals("th")) {
            // handle manual TH cells
            processRow(table.addHeaderRow(), child, converter);

          } else {
            // OK, must be a table row.
            processRow(table.addBodyRow(), child, converter);

          }
        }
      }
    }

    // OK, now render this sucker
    Options.Tables opts = converter.options.getTables();
    converter.output.startBlock();
    table.renderTable(converter.output, opts.isColspanEnabled(), opts.isRenderedAsCode());
    converter.output.endBlock();
  }
View Full Code Here

TOP

Related Classes of com.overzealous.remark.util.MarkdownTable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.