Last active
March 24, 2022 12:39
-
-
Save hfhbd/7ffb4b94e7f9b9035939e26b40999532 to your computer and use it in GitHub Desktop.
Latex extractor for IntelliJ Ultimate Database Tool
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.intellij.database.extensions.* | |
/* | |
* Available context bindings: | |
* COLUMNS List<DataColumn> | |
* ROWS Iterable<DataRow> | |
* OUT { append() } | |
* FORMATTER { format(row, col); formatValue(Object, col) } | |
* TRANSPOSED Boolean | |
* plus ALL_COLUMNS, TABLE, DIALECT | |
* | |
* where: | |
* DataRow { rowNumber(); first(); last(); data(): List<Object>; value(column): Object } | |
* DataColumn { columnNumber(), name() } | |
*/ | |
val out = bindings["OUT"] as java.lang.Appendable | |
val columns = bindings["COLUMNS"] as List<DataColumn> | |
val rows = bindings["ROWS"] as Iterable<DataRow> | |
val format = bindings["FORMATTER"] as ValueFormatter | |
out.apply { | |
append( | |
""" | |
\begin{table}[] | |
\centering | |
""".trimIndent() | |
) | |
append("\\begin{tabular}{${columns.joinToString(separator = "|") { "l" }}}") | |
appendLine() | |
append(columns.joinToString(separator = " & ", postfix = """\\ \hline""") { | |
it.name() | |
}) | |
for (row in rows) { | |
appendLine() | |
append(columns.joinToString(separator = " & ", postfix = """\\""") { | |
format.format(row, it) | |
}) | |
} | |
append(""" | |
\end{tabular} | |
\caption{} | |
\label{tab:} | |
\end{table} | |
""") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment