jakewharton / picnic Goto Github PK
View Code? Open in Web Editor NEWA Kotlin DSL and Java/Kotlin builder API for constructing HTML-like tables which can be rendered to text
License: Apache License 2.0
A Kotlin DSL and Java/Kotlin builder API for constructing HTML-like tables which can be rendered to text
License: Apache License 2.0
Hi, thanks for this useful library! I'm using it in a Java project and I wanted to try out the ROUNDED and ASCII styles, but I cannot seem to access Table.renderText
(or Table.render
). Is this feature meant to be available from Java?
data classes are bad for public API
Picnic could be able to do build
┌───────────┬──────────────┐
│ columnA │ columnB │
├───────────┼──────────────┤
│ itemA1 │ B │
│ itemA2 │ C │
│ itemA3 │ D │
└───────────┴──────────────┘
But right now I can only build
┌───────────┬──────────────┐
│ columnA │ columnB │
├───────────┼──────────────┤
│ itemA1 │ B │
│ itemA2 │ C │
│ itemA3 │ D │
Using header (border=true) + body(borderLeft=true, borderRight=true)
When using picnic 0.6.0 I'm getting:
The dependency com.jakewharton.picnic:picnic:0.6.0 was published in the legacy mode. Support for such dependencies will be removed in the future. See https://kotl.in/0b5kn8 for details.
Seems like tooling needs to be udpated, a new release needs to be cut and then we're all good.
In the tables I'm generating, I have several sections. It would useful to be able to add a separator between these sections.
Might be nitpicking here, but is the copyright year in README.md really 2015?
I have a picnic table where I am trying to render links using markdown (through mordant 2.0 markdown support). The cell breaks the table though because the width is calculated with the entire string and not just the visible part. Is there any way to work this around?
Tables to be correctly drawn with unicode characters
Tables are messed up with unicode characters
Version: 0.4.0
OS: MacOS BigSur - english language
IDE: IntelliJ Idea Ultimate 2020.2
Kotlin: 1.4.0
Project type: Multiplatform, JVM variant only for this module ( stdlib-jdk8 )
JDK: 14
┌──────────────────────────────────────────────────────────────────────────────────┬─────────────┬───────────────────┐
│ 呀〈KIBA〉 ~暗黒騎士鎧伝~ │ Year 2011 │ Tmdb id: 257171 │
├──────────────────────────────────────────────────────────────────────────────────┴─────────────┴───────────────────┤
│ Actors: Masaki Kyômoto, Mika Hijii, Leah Dizon, Mikoto Inoue, Raima Hiramatsu, Kazuhiko Inoue, Miz... │
├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Genres: Fantasy, Action, Adventure │
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
"\u001B[46mWelcome to My App!\u001B[0m"
┌───────────────────────────────────────────────────────────────────┐
│ │
│ Welcome to My App! │
│ │
├──────────────────────────────────┬────────────────────────────────┤
│ │ commands │
├──────────────────────────────────┼───────┬────────────────┬───────┤
│ Search a Movie by title │ 1 │ search │ s │
├──────────────────────────────────┼───────┼────────────────┼───────┤
│ Rate a Movie by id │ 2 │ rate │ r │
├──────────────────────────────────┼───────┼────────────────┼───────┤
│ Get suggested Movies for you │ 3 │ suggestion │ g │
└──────────────────────────────────┴───────┴────────────────┴───────┘
Imagine this table
table {
style {
borderStyle = Solid
}
cellStyle {
borderLeft = true
borderRight = true
}
header {
cellStyle {
border = true
alignment = BottomLeft
}
row("Header 1", "Header 2")
}
body {
repeat(3) {
row("row $it", "row $it")
}
}
}
It would render:
┌────────┬────────┐
│Header 1│Header 2│
├────────┼────────┤
│row 0 │row 0 │
│row 1 │row 1 │
│row 2 │row 2 │
Notice that the border at the bottom is missing. The fix is could be to render a different row in the body
row {
cell("last row") {
borderBottom = true
}
cell("last row") {
borderBottom = true
}
}
Or another fix could be to render a footer:
footer {
cellStyle {
borderBottom = true
}
row("Footer 1", "Footer 2")
}
But this is annoying, because the last row is a special case. I'd rather would like to specify a footer like this:
footer {
cellStyle {
border = true
}
}
But this doesn't render anything since there is no row.
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
This repository currently has no open or pending branches.
.github/workflows/build.yaml
actions/checkout v4
actions/setup-java v4
gradle/actions v4
ffurrer2/extract-release-notes v2
softprops/action-gh-release v2
gradle.properties
settings.gradle
build.gradle
org.jetbrains.kotlin:kotlin-gradle-plugin 2.0.10
org.jetbrains.dokka:dokka-gradle-plugin 1.9.20
com.diffplug.spotless:spotless-plugin-gradle 6.25.0
ru.vyarus:gradle-animalsniffer-plugin 1.7.1
com.vanniktech:gradle-maven-publish-plugin 0.29.0
org.codehaus.mojo.signature:java18 1.0
net.sf.androidscents.signature:android-api-level-21 5.0.1_r2
picnic/gradle.properties
picnic/build.gradle
com.jakewharton.crossword:crossword 0.3.0
sample/build.gradle
com.github.ajalt:mordant 1.2.1
gradle/wrapper/gradle-wrapper.properties
gradle 8.9
Thank's for the great library. I use it in some of my projects and very happy with results (especially combined with Mosaic).
In one of my projects I've faced with requirement to output data as CSV along with human-readable tables. I've came up with my
own solution (not a rocket science) and got thinking that there could be some CSV related API in Picnic.
So my questions are:
Thank you
It would be great if we could pass a PrintStream
to the renderText
call so that large tables can be streamed out immediately and to reduce the memory footprint.
It appears that the unicode characters are not generated or recognized correctly on Windows.
I've opened a PR to add a GitHub action to build on Windows, Linux and Mac; the Windows build always fails, though, because the tables look like this:
? compressed ? uncompressed
?????????????????????????????????????????????????????????????????
APK ? old ? new ? diff ? old ? new ? diff
???????????????????????????????????????????????????????????????????????????
dex ? 664.8 KiB ? 664.8 KiB ? -25 B ? 1.5 MiB ? 1.5 MiB ? -112 B
arsc ? 201.7 KiB ? 201.7 KiB ? 0 B ? 201.6 KiB ? 201.6 KiB ? 0 B
manifest ? 1.4 KiB ? 1.4 KiB ? 0 B ? 4.2 KiB ? 4.2 KiB ? 0 B
res ? 418.2 KiB ? 418.2 KiB ? -14 B ? 488.3 KiB ? 488.3 KiB ? 0 B
asset ? 0 B ? 0 B ? 0 B ? 0 B ? 0 B ? 0 B
other ? 37.1 KiB ? 37.1 KiB ? 0 B ? 36.3 KiB ? 36.3 KiB ? 0 B
???????????????????????????????????????????????????????????????????????????
See build results here.
There's nothing JVM-specific
I wonder if there is a simple quick start example for the usage of picnic in Java? A minimal introduction to Java usage would be great.
Migrate the DSL to use these behind-the-scenes instead of their own.
I'm using picnic to print out tables for a command line tool. On some tables, I'd like to have hyperlink support. Do you have any ideas / suggestion how to have them clickable by iTerm?
iTerms and other consoles have support for links:
printf '\e]8;;http://example.com\e\\This is a link\e]8;;\e\\\n'
The 0.6.0 jar in maven central is missing the .class
files.
0.3.0 specifically commit: 2ef687d
introduced a dependency on java8 String
I was using the lib inside an android application (mainly running on android6 devices).
project is setup:
Project compile without any issue or warning but the app ultimately crash when invoking the codePoints method.
E java.lang.NoSuchMethodError: No virtual method codePoints()Ljava/util/stream/IntStream; in class Ljava/lang/String; or its super classes (declaration of 'java.lang.String' appears in /system/framework/core-libart.jar) E at com.jakewharton.picnic.SimpleLayout.draw(textLayout.kt:62) E at com.jakewharton.picnic.TextRendering.render(textRender.kt:314) E at com.jakewharton.picnic.TextRendering.render$default(textRender.kt:16)
Tables to be correctly drawn with ANSI color codes
Tables are messed up with Chinese ANSI color codes
Version: 0.4.0
OS: MacOS BigSur - english language
IDE: IntelliJ Idea Ultimate 2020.2
Kotlin: 1.4.0
Project type: Multiplatform, JVM variant only for this module ( stdlib-jdk8 )
JDK: 14
"\u001B[46mWelcome to My App!\u001B[0m"
┌───────────────────────────────────────────────────────────────────┐
│ │
│ Welcome to My App! │
│ │
├──────────────────────────────────┬────────────────────────────────┤
│ │ commands │
├──────────────────────────────────┼───────┬────────────────┬───────┤
│ Search a Movie by title │ 1 │ search │ s │
├──────────────────────────────────┼───────┼────────────────┼───────┤
│ Rate a Movie by id │ 2 │ rate │ r │
├──────────────────────────────────┼───────┼────────────────┼───────┤
│ Get suggested Movies for you │ 3 │ suggestion │ g │
└──────────────────────────────────┴───────┴────────────────┴───────┘
Either by package or by artifact, or both. The DSL really pollutes the namespace in javadoc.
SimpleTextLayout
naively assumes char
count is width
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.