I have a Jekyll blog, I am trying to switch from this
{:lang='bash'}
#!/bin/sh
echo 'Hello World!'
To this
{:lang='bash'}
{% include program-w32-build-100.sh %}
The include inserts the text from the file, and the lang='bash' is supposed to highlight it. Since the text in the file is not tabbed, it does not get highlighted. Is there a way to make this happen?
jason.the-graham.com/2010/11/21/kramdown_support_for_jekyll
Lucky me!
You can do this
{:lang='bash'}
~~~
{% include rtmpdump-w32-build-100.sh %}
~~~
§ Fenced Code Blocks
Related
I'd like to create something like a shortcode for a blockquote in Jekyll. It should include the quote source in a nicely formatted way.
The shortcode could look like this:
{% quote author="My Author" %}
This is the quoted content
spanning multiple lines
And paragraphs
{% endquote %}
What's the best way to achieve this in Jekyll? Can it be that there is no way to provide multiple arguments to a Jekyll tag plugin?
I have found a blog post that provides multiple attributes using string concatenation or JSON.
My Research
I have found two systems in Jekyll that can be used similar to shortcodes:
HTML Includes
Custom Tags
To summarize, both methods only provide a single attribute to the Ruby code, the content. Below, you will find the limitations of both solutions.
HTML Includes limiations
https://jekyllrb.com/docs/includes/
An include in use looks like this:
{% include note.html content=download_note %}
It is possible to use content from captures for parameters, so we could create the following include file:
<blockquote>
{{ include.quote | markdownify }}
<p><em>{{ include.author }}</em></p>
</blockquote>
And use it in a blog post like this:
{% capture quote %}
This is the quote content
spanning multiple lines
And paragraphs
{% endcapture %}
{% include quote.html quote=quote author="My Author" %}
It works, but in my opinion, it's not really a nice approach to use when writing blog posts.
Custom Tags limiations
https://jekyllrb.com/docs/plugins/tags/
Sounds promising, but the documentation only shows two ways to use them:
{% render_time page rendered at: %}
and
{% render_time %}
page rendered at:
{% endrender_time %}
I have a little problem trying to generate quotes in a html file throught a rmarkdown. Actually, I would like to generate some jinja inside my html and there come the problem.
If I do not escape the quote:
{% extends "base.html" %} in rmarkdown become
{% extends “base.html” %} in the html file which produce an error.
And if I do escape the quote:
{% extends \"base.html\" %} in rmarkdown become
{% extends "base.html" %} in the html file which produce an error too.
What is the solution ?
Thanks by advance !
I got the answer after a discussion on another channel.
It is necessary to add a option in the yaml below the html_document:
self_contained: false
and use escape quotes \" to avoid smart transformations.
I have this Liquid template which looks like this:
# /_includes/slideshow.html
{% for image in {{ include.images }} %}
...
{% endfor %}
which I'm trying to use with a YAML file (for my Jekyll site) like this:
# /index.md
{% include slideshow.html images='site.data.homepage_images' %}
The reason I see this failing is because my include variable {{ include.images }} resolves to a string within the for loop. Is there a different way to accomplish this? I'm still rather new to Liquid, YAML, Jekyll, and well, web development altogether, so any help in doing this is much appreciated!
(Note: the problem goes away if I replace {{ include.images }} with site.data.homepage_images.)
Additionally, the reason why I'm doing this (and why that crude fix isn't the solution I'm looking for) is for the ability to inject my image slideshow elsewhere around my site. It'd save a lot of code to abuse my include variable in this way.
Correct syntax in for loop is : {% for image in include.images %}
I have a blog that is based on jekyll now.But the issue I face is that the it is very difficult for me to write code here.I have already tried using <code> and ~~~ruby etc.None of them worked.This is the site for the blog.And this is the specific one I am looking at.This specifically is the repository where the blog is hosted.
No magic in Jekyll. Just Read The F.. Documentation (RTFM). See http://jekyllrb.com/docs/templates/#code-snippet-highlighting
{% highlight ruby %}
def foo
puts 'foo'
end
{% endhighlight %}
This just works.
Edit: be sure to leave a new empty line before the opening tag
<p>He had implemented ...<p>
{% highlight ruby %}
How can I number the code lines which are highlighted using pygments in Jekyll?
According to the Liquid Extensions wiki page of the Jekyll documentation, the highlight Liquid tag has an optional second parameter, which may have the value linenos to turn on line numbering:
{% highlight language linenos %}
your code here
{% endhighlight %}
Use it with caution. With linenos the line numbers are actually inserted in the code's text, so will be impossible to copy the code block without them. (This could be solved by letting the visitor to $('.lineno').toggle() the line numbers' visibility. Works in Firefox, not sure if is portable.)
Update: Better use linenos=table:
{% highlight language linenos=table %}
your code here
{% endhighlight %}
That will place the code in a table with two cells: first td all the line numbers, second td the code itself. This makes possible to select only the code, without the line numbers.