{"id":13565952,"url":"https://github.com/plesk/tablemark","last_synced_at":"2025-04-03T23:30:47.691Z","repository":{"id":57137245,"uuid":"380213715","full_name":"plesk/tablemark","owner":"plesk","description":"Generate markdown tables from JSON data.","archived":false,"fork":true,"pushed_at":"2021-06-29T11:18:16.000Z","size":62,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T05:37:03.816Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"haltcase/tablemark","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/plesk.png","metadata":{"files":{"readme":"readme.md","changelog":"changelog.md","contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-25T11:15:16.000Z","updated_at":"2021-10-18T01:28:49.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/plesk/tablemark","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plesk%2Ftablemark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plesk%2Ftablemark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plesk%2Ftablemark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plesk%2Ftablemark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/plesk","download_url":"https://codeload.github.com/plesk/tablemark/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247097617,"owners_count":20883121,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T13:01:58.778Z","updated_at":"2025-04-03T23:30:46.641Z","avatar_url":"https://github.com/plesk.png","language":"JavaScript","readme":"# tablemark \n\n\u003e Generate markdown tables from JSON data.\n\nParses arrays of objects into markdown tables, complete with configuration\nfor renaming columns and left, center, or right-aligning them.\n\nThis is a patched version of [citycide/tablemark](https://github.com/citycide/tablemark) library which can be used in NX/React/ReduxToolkit/TypeScript stack. \n\n## installation\n\n```sh\nyarn add @plesk-tools/tablemark\n```\n\n## usage\n\n```js\nconst tablemark = require('tablemark')\n```\n\n```js\ntablemark([\n  { name: 'Bob', age: 21, isCool: false },\n  { name: 'Sarah', age: 22, isCool: true },\n  { name: 'Lee', age: 23, isCool: true }\n])\n\n// | Name  | Age   | Is cool |\n// | ----- | ----- | ------- |\n// | Bob   | 21    | false   |\n// | Sarah | 22    | true    |\n// | Lee   | 23    | true    |\n```\n\n... displays as:\n\n| Name  | Age   | Is cool |\n| ----- | ----- | ------- |\n| Bob   | 21    | false   |\n| Sarah | 22    | true    |\n| Lee   | 23    | true    |\n\n## api\n\n```js\ntablemark(input[, options = {}])\n```\n\n\u003e **Arguments**\n\n- `{Array\u003cObject\u003e} input`: the data to table-ify\n- `{Object} [options = {}]`\n\n| key            | type         | default    | description                                    |\n| :------------: | :----------: | :--------: | ---------------------------------------------- |\n| `columns`      | `\u003cArray\u003e`    | -          | Array of column descriptors.                   |\n| `caseHeaders`  | `\u003cBoolean\u003e`  | `true`     | Sentence case headers derived from keys.       |\n| `stringify`    | `\u003cFunction\u003e` | -          | Provide a custom \"toString\" function.          |\n| `wrap.width`   | `\u003cNumber\u003e`   | `Infinity` | Wrap texts at this length.                     |\n| `wrap.gutters` | `\u003cBoolean\u003e`  | `false`    | Add sides (`\\| \u003ccontent\u003e \\|`) to wrapped rows. |\n\nThe `columns` array can either contain objects, in which case their\n`name` and `align` properties will be used to alter the display of\nthe column in the table, or any other type which will be coerced\nto a string if necessary and used as a replacement for the column\nname.\n\n### `columns`\n\n```js\ntablemark([\n  { name: 'Bob', age: 21, isCool: false },\n  { name: 'Sarah', age: 22, isCool: true },\n  { name: 'Lee', age: 23, isCool: true }\n], {\n  columns: [\n    'first name',\n    { name: 'how old', align: 'center' },\n    'are they cool'\n  ]\n})\n\n// | first name | how old | are they cool |\n// | ---------- | :-----: | ------------- |\n// | Bob        |   21    | false         |\n// | Sarah      |   22    | true          |\n// | Lee        |   23    | true          |\n```\n\n... displays as:\n\n| first name | how old | are they cool |\n| ---------- | :-----: | ------------- |\n| Bob        |   21    | false         |\n| Sarah      |   22    | true          |\n| Lee        |   23    | true          |\n\n### `stringify`\n\n```js\ntablemark([\n  { name: 'Bob', pet_owner: true, studying: false },\n  { name: 'Sarah', pet_owner: false, studying: true },\n  { name: 'Sarah', pet_owner: true, studying: true }\n], {\n  stringify,\n  columns: [\n    { align: 'left' },\n    { align: 'center' },\n    { align: 'center' }\n  ]\n})\n\nfunction stringify (v) {\n  if (v === true) return '✔'\n  if (!v) return ''\n  return v\n}\n\n// | Name  | Pet owner | Studying |\n// | :---- | :-------: | :------: |\n// | Bob   |     ✔︎     |          |\n// | Sarah |           |    ✔     |\n// | Lee   |     ✔     |    ✔     |\n```\n\n### `wrap`\n\nTo output valid [GitHub Flavored Markdown](https://github.github.com/gfm/) a\ncell must not contain newlines. Consider replacing those with `\u003cbr /\u003e` (e.g.\nusing the `stringify` option).\n\nSet the `wrap.width` option to wrap any content at that length onto a new\nadjacent line:\n\n```js\ntablemark([\n  { star: false, name: 'Benjamin' },\n  { star: true, name: 'Jet Li' }\n], { wrap: { width: 5 } })\n\n// | Star  | Name  |\n// | ----- | ----- |\n// | false | Benja |\n//           min\n// | true  | Jet   |\n//           Li\n```\n\nEnable `wrap.gutters` to add pipes on all lines:\n\n```js\ntablemark([\n  { star: false, name: 'Benjamin' },\n  { star: true, name: 'Jet Li' }\n], { wrap: { width: 5, gutters: true } })\n\n// | Star  | Name  |\n// | ----- | ----- |\n// | false | Benja |\n// |       | min   |\n// | true  | Jet   |\n// |       | Li    |\n```\n\n## see also\n\n- [`tablemark-cli`](https://github.com/citycide/tablemark-cli) \u0026ndash; use this module from the command line\n\n## contributing\n\nSearch the [issues](https://github.com/citycide/tablemark) if you come\nacross any trouble, open a new one if it hasn't been posted, or, if you're\nable, open a [pull request](https://help.github.com/articles/about-pull-requests/).\nContributions of any kind are welcome in this project.\n\nThe following people have already contributed their time and effort:\n\n* Thomas Jensen (**[@tjconcept](https://github.com/tjconcept)**)\n\nThank you!\n\n## license\n\nMIT © Bo Lingen / citycide\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplesk%2Ftablemark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplesk%2Ftablemark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplesk%2Ftablemark/lists"}