Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example in README duplicates img tags #97

Closed
johnbeech opened this issue Feb 14, 2023 · 1 comment · Fixed by #100
Closed

Example in README duplicates img tags #97

johnbeech opened this issue Feb 14, 2023 · 1 comment · Fixed by #100

Comments

@johnbeech
Copy link
Contributor

Test file:

const json2md = require("json2md")

console.log(json2md([
    { h1: "JSON To Markdown" }
  , { blockquote: "A JSON to Markdown converter." }
  , { img: [
        { title: "Some image", source: "https://example.com/some-image.png" }
      , { title: "Another image", source: "https://example.com/some-image1.png" }
      , { title: "Yet another image", source: "https://example.com/some-image2.png" }
      ]
    }
  , { h2: "Features" }
  , { ul: [
        "Easy to use"
      , "You can programmatically generate Markdown content"
      , "..."
      ]
    }
  , { h2: "How to contribute" }
  , { ol: [
        "Fork the project"
      , "Create your branch"
      , "Raise a pull request"
      ]
    }
  , { h2: "Code blocks" }
  , { p: "Below you can see a code block example." }
  , { "code": {
        language: "js"
      , content: [
          "function sum (a, b) {"
        , "   return a + b"
        , "}"
        , "sum(1, 2)"
        ]
      }
    }
]))

Actual output:

  # JSON To Markdown

  > A JSON to Markdown converter.

  ![](https://example.com/some-image.png "Some image")
  ![](https://example.com/some-image.png "Some image")

  ![](https://example.com/some-image1.png "Another image")
  ![](https://example.com/some-image1.png "Another image")

  ![](https://example.com/some-image2.png "Yet another image")
  ![](https://example.com/some-image2.png "Yet another image")


  ## Features


  - Easy to use
  - You can programmatically generate Markdown content
  - ...

  ## How to contribute


  1. Fork the project
  2. Create your branch
  3. Raise a pull request

  ## Code blocks


  Below you can see a code block example.

  ```js
  function sum (a, b) {
     return a + b
  }
  sum(1, 2)
  ```

Note the duplicated images; three in the input, three pairs, six total images in the output.

johnbeech added a commit to johnbeech/json2md that referenced this issue Feb 14, 2023
@johnbeech
Copy link
Contributor Author

Created a PR with a test case to demonstrate the issue:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant