| Bytes | Lang | Time | Link |
|---|---|---|---|
| 056 | Perl 5 + p0l051 | 240607T165602Z | Dom Hast |
| 125 | TypeScript’s type system | 240607T153021Z | noodle m |
| 038 | Pip | 171220T073257Z | DLosc |
| 092 | PHP | 170620T214125Z | Jör |
| 126 | MATLAB/Octave | 170619T202634Z | Tom Carp |
| 050 | 05AB1E | 170619T193137Z | Erik the |
| 091 | Python 3 | 170619T193517Z | totallyh |
| 035 | V | 170619T193047Z | DJMcMayh |
| 048 | Retina | 170619T191624Z | ETHprodu |
| 085 | Ruby | 170619T212958Z | Value In |
| 073 | JavaScript ES6 | 170619T211402Z | Neil |
| 101 | Python 2 | 170619T194318Z | Rod |
TypeScript’s type system, 125 bytes
type F<S>=S extends`# [${infer L}]${infer S}
${any} ${infer C}
${any}
[TIO-${any} ${infer T}`?`${L}${S}[\`${C}\`](${T})`:S
Golfs from trivial solution:
- Omit some newlines
- Omit
]:after TIO link because you just need to get what’s after the space
Pip, 43 39 38 bytes
[a@>3DC']": [`"g@-6|>s"`]("(g@v^s1)')]
Takes the lines as separate command-line arguments. An example invocation could look like:
> pip.py -f convert.pip "# [05AB1E], 1 byte" "" " Ô" "" "[Try it online!][TIO-j3v72bss]" "" "[05AB1E]: https://github.com/Adriandmen/05AB1E" "[TIO-j3v72bss]: https://tio.run/##MzBNTDJM/f//8JT//zNSgSAnJycfDAA \"05AB1E – Try It Online\""
though actually this doesn't work for me because Windows cmd complains about the Ô... [inarticulate muttering]
--At any rate, it works on TIO. Or, use the -r flag and take input from lines of stdin instead.
Assumes that the language name will not contain ] (which would break the markdown anyway).
Explanation
g is list of cmdline args; a is 1st arg;
s is space; v is -1 (implicit)
[ ] Build a list with these elements:
a@>3 1st line, sans first three characters,
DC'] with the ] character deleted
": [`" This string
g@-6 6th line from the end (the code)
|>s with leading spaces stripped
"`](" This string
g@v Last line (containing the URL)
^s split on spaces
( 1) get element at index 1
') This character
By default, the list is concatenated and printed
PHP, 92 bytes
<?=preg_filter("<...(.+)\](, \d+ \w+).* {4}(\S+).*: (\S+).*>s","$1$2: [`$3`]($4)",$_GET[0]);
MATLAB/Octave, 120 126 bytes
@(a)strjoin(regexprep(strsplit(a,'\n'),{'\[.+\]: (.+) ".+','^[\[<].+','# \[(.+)\](.+)','^ +'},{'`]($1)','','$1$2: [`',''}),'')
This should work. For MATLAB it won't work with Unicode characters though I don't think, mostly because MATLAB sucks when it comes to odd characters. However it will work with Unicode for Octave, or at least TIO seems to be able to cope.
It should also handle submissions both with and without the <-- --> syntax highlighting.
Updates:
- Added 4 bytes as I missed the
@(a)when copying over - Added 2 bytes to add back ticks around the code in the output
05AB1E, 50 bytes
']¡J¦¦¦|J|`‚ʒнðQ}`ðÛ|D`θ'"Êi\|ë\}θ#1èr"ÿ: [`ÿ`](ÿ)
Now supports syntax highlighting too!
н is replaced by 0è and θ is replaced by ®è since those aren't pulled to TIO yet.
I just wonder how to shorten ¦¦¦...
Python 3, 113 103 98 91 bytes
-1 byte thanks to Value Ink.
If you can, I could totally use some help with the regex. ><
lambda s:re.sub('(?s)# .(.*)](.*?)\n.* {4}(.*?)\n.+: (.*)',r'\1\2: [`\3`](\4)',s)
import re
Retina, 54 48 52 57 48 bytes
Saved 1 byte thanks to @MartinEnder, 1 byte thanks to @Riley
...(.+)[^@]+ (.+)[^@]+:
$1: [`$2`](
1`]
$
)
Try it online! This assumes there won't be an @ in the language name, which should be fine...
Ruby, 85 bytes
->s{s[/.*/].gsub(/# .|\]/){}+": [`#{s[/(?<= )\S.*/]}`](#{s=~/TIO-\w+.: (\S+)/;$1})"}
JavaScript (ES6), 73 bytes
f=
s=>s.replace(/...(.*)](.*)[^]+ (.*)[^]+: (.*) ".*/,"$1$2: [`$3`]($4)")
<textarea rows=8 cols=75 oninput=o.textContent=this.value==f(this.value)?``:f(this.value)></textarea><pre id=o>
Python 2, 101 bytes
a=input().split('\n')
print'%s%s: [`%s`](%s)'%tuple(a[0][3:].split(']')+[a[-6][4:],a[-1].split()[1]])