arraysjsongithubmarkdownreadme

Dynamic markdown from json in Github readme.md


What I want is I have a list of some lines (Basically data like a quote) in JSON format.

How can I display a random line in Readme.md from the JSON file.

Example of JSON file:

[
    "Hello, world",
    "How you doing?",
    "Hello, folks",
    "How are you?"
]

I just want a random item from that list to be in the Readme.md File every time page loaded.


Solution

  • Markdown is a document format. It is designed to produce documents for reading and viewing, but is not designed to embed scripting or other dynamic content.

    Even if you could embed this kind of data into your Markdown, GitHub does not execute user JavaScript code as part of README documents, so this won't be possible as part of your README. That's because doing so is a security problem and would allow a malicious repository owner to take over your GitHub account.

    If you're generating Markdown into HTML for some other type of hosted page, then this is possible by modifying the HTML as normal.