Search code examples
markdowngithub-flavored-markdown

Is it possible to create a toggle (switch) in MarkDown?


I want to achieve something like this for a documentation that is written with MarkDown:enter image description here

The toggle will show this sample code either in Objective-C or Swift. I couldn't find anything in MD's documentation that shows that this is possible. Any suggestions?


Solution

  • This is not possible with regular Markdown or GitHub-flavoured Markdown.

    Markdown, generally, outputs HTML. The language itself is deliberately very simple:

    Markdown is not a replacement for HTML, or even close to it. Its syntax is very small, corresponding only to a very small subset of HTML tags ... The idea for Markdown is to make it easy to read, write, and edit prose.

    What you want to do needs JavaScript.

    You could potentially write some JavaScript that works with your Markdown output, though depending on where you plan to host the HTML you may have trouble with that, too.