src-d / blog

source{d} blog
https://blog.sourced.tech/
GNU General Public License v3.0
27 stars 41 forks source link

new short-code to embed code #198

Closed campoy closed 6 years ago

campoy commented 6 years ago

Previously we were using the triple backtick to indicate code, copy pasting code into the post.

As @dpordomingo proposed I created a new short-code named code which given the highlighting language.

So we can replace sections like this one:

screen shot 2018-04-09 at 3 26 29 pm

which is rendered as:

screen shot 2018-04-09 at 3 26 18 pm

With a simple short code call:

{{% code "/post/c-on-bigquery/udf.js" javascript %}}

Which displays as:

screen shot 2018-04-09 at 3 37 17 pm

Note that the parameters are positional and the highlight language is optional.

vmarkovtsev commented 6 years ago

@campoy Looks like this one https://stackoverflow.com/a/45421343

campoy commented 6 years ago

yeah, but that doesn't exist on our theme. LGTM?

campoy commented 6 years ago

Happy to change it later if we see any way to improve the short code.

dpordomingo commented 6 years ago

Thanks for adding it :)