Skip to content

Table doesn't fill boolean values #108

@josobrate

Description

@josobrate

I'm using json2md like this:

json2md([
  { h1: "Table" },
  {
    table: {
      headers: ["id", "name", "active"],
      rows: [
        {
          id: 1,
          name: "token-0123456789",
          active: false,
        },
        {
          id: 2,
          name: "token-9876543210",
          active: true,
        },
      ],
      pretty: true,
    },
  },
]);

Strings and numbers work, but boolean values are ignored, the output is:

# Table

| id  |       name       | active |
| --- | ---------------- | ------ |
| 1   | token-0123456789 |        |
| 2   | token-9876543210 |        |

Expected output:

# Table

| id  |       name       | active |
| --- | ---------------- | ------ |
| 1   | token-0123456789 | false  |
| 2   | token-9876543210 | true   |

Editing file index.js:54 fixes the problem for me, but I'm not sure if this is the right approach:

-    if (typeof data === "string" || typeof data === "number") {
+    if (typeof data === "string" || typeof data === "number" || typeof data === "boolean") {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions