Skip to content

Instantly share code, notes, and snippets.

@classycode96
Created May 29, 2019 14:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save classycode96/315835f4ddd419f452d9dc0e11b88a0b to your computer and use it in GitHub Desktop.
Save classycode96/315835f4ddd419f452d9dc0e11b88a0b to your computer and use it in GitHub Desktop.
A Gist for extracting Markdown-Styled tables
SEP = " | "
NEWLINE = System.getProperty("line.separator")
OUT.append("| ")
COLUMNS.each { column ->
OUT.append(column.name()).append(" | ")
}
OUT.append(NEWLINE)
OUT.append("| ")
COLUMNS.each { column ->
OUT.append("---|")
}
OUT.append(NEWLINE)
def record(columns, dataRow) {
OUT.append("| ")
columns.each { column ->
def value = dataRow.value(column)
def stringValue = value != null ? FORMATTER.format(dataRow, column) : ""
OUT.append(stringValue).append(" | ")
}
OUT.append(NEWLINE)
}
ROWS.each { row -> record(COLUMNS, row) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment