Context
Just look around! Whenever someone posts an answer, the same template is followed over and over again! A first line with the byte count and language name. Then the code. Then the TIO link. This is the basic skeleton almost everyone follows.
Task
Your task, should you choose to accept it, is to write a program/function/procedure/etc that takes as input the variable bits and produces the basic CGCC answer.
Input
The language name, some code and a TIO link, in any sensible formats. For the language name and the TIO link, a string is suggested. For the code, sensible formats include a string with possibly some newlines, or a list of strings, one string per line.
Additionally, you may also take the byte count as input. If you don't, you have to compute it yourself (if you compute it yourself, you can assume the byte count equals the length of the code string).
You have to support that the input strings may contain any printable, non-whitespace ASCII characters plus the space. The only exclusion being the newlines in the source code. You don't have to worry about the weird characters used by golfing languages in their code pages.
The inputs may be ordered in any way you like.
Output
You should output this raw content:
# {name}, {byte count} bytes
{code}
You can [try it online][tio]!
[tio]: {link}
Where {name}
, {byte count}
, {code}
and {link}
should be filled in by your code. Three of those are inputs, the byte count should be computed within your code if you chose not to receive it as input (you can assume the byte count is equal to the number of characters in the code
argument). Beware that the code given may be multiline, in which case the {code}
section must be indented by 4 spaces for each line of code.
Test cases
You can check some test cases.
This is code-golf, so shortest answer in bytes wins. If you liked the challenge, consider upvoting it... And happy golfing!
<pre><code>
and HTML formatting to insert the tab, along with a bunch of other edge cases. \$\endgroup\$\t
, the code needs to be formatted differently to display it correctly, or something, so on TIO it will emit something like<pre><code>	print 3</code></pre>
instead of(four spaces)(tab)print 3
(because otherwise SE will change the tab into 4 spaces or something). Do we need to handle this case??? \$\endgroup\$