Add DataFrame.renderToMarkdown(): String function#1760
Add DataFrame.renderToMarkdown(): String function#1760
Conversation
What kind of quirks do you mean? |
| return PreparedTable(header, values, rowsCount, nrow) | ||
| } | ||
|
|
||
| public fun AnyFrame.renderToMarkdown( |
There was a problem hiding this comment.
I believe this deserves its own file, no? :)
| val expected = | ||
| """ | ||
| | | name | age | city | | ||
| |---:|---:|---:|---:| |
There was a problem hiding this comment.
what do these colons do? I don't think I've seen them before in MD tables
There was a problem hiding this comment.
ah! it's alignment, right? Uhm, maybe we should have "no alignment" as an option, as well as right/left alignment. There are some right-to-left languages that could cause issues with a default alignment. (Actually, they probably already break tables like these, they broke our toString() very much too)
| // header | ||
| sb.append("|") | ||
| for (col in table.header) { | ||
| sb.append(" ${col.replace("|", "\\|")} |") |
There was a problem hiding this comment.
isn't this logic already applied in prepareTable?
There was a problem hiding this comment.
ah, no it isn't, maybe it should :)
| escapeValue: (String) -> String = { it }, | ||
| ): PreparedTable { | ||
| val rowsCount = rowsLimit.coerceAtMost(nrow) | ||
| val cols = if (rowIndex) listOf((0 until rowsCount).toColumn()) + columns() else columns() |
There was a problem hiding this comment.
do you know ..< for until? :)
| val decimalFormat = | ||
| if (precision >= 0) RendererDecimalFormat.fromPrecision(precision) else RendererDecimalFormat.of("%e") | ||
| top.values().map { | ||
| escapeValue(renderValueForStdout(it, valueLimit, decimalFormat = decimalFormat).truncatedContent) |
There was a problem hiding this comment.
maybe create a new issue for exploring rendering nested frames as <details> like toStaticHtml? or at least mention this option in some kdoc :) Speaking of... small kdoc please? :))
fixes #525
First, i added more tests on original renderToString. Then a little refactoring to extract common logic. +new function
Original rendering has some quirks that can be seen in test asserts. For now i just preserved it as is, but probably let's improve it as well - it will be more obvious with new tests