Jekyll incorrect syntax highlighting - syntax-highlighting

I want to have correct syntax highlighting for a small snippet of C code. I'm currently using the following tags:
{% highlight c %}
... code snippet ...
{% endhighlight %}
When I serve my page locally using "jekyll serve" everything works as expected. However, when I do a git push and view the page on the web the results of the syntax highlighting are incorrect. A number of the lines incorrectly appear as comments.
If I inspect the source locally, I see the following:
<code class="language-c" data-lang="c">
...
</code>
On the other hand if I inspect the source on the web I see:
<code class="c">
...
</code>
I'm not sure what is causing the issue. This is my first Jekyll website so I'm very inexperienced with the tool. Any help or suggestions to fix the issue will be greatly appreciated.
You can view the source at https://github.com/grouma/grouma.github.io and the corresponding page at http://garyroumanis.com/2014/07/05/sous-vide/.
EDIT
I have changed the tag to {% highlight c++ %} and it works as expected. Quite confused but at least it is readable for the time being.

This has been fixed since Jekyll v2.1.0: https://github.com/jekyll/jekyll/pull/2511

Related

VScode - Laravel blade syntax - highlighting matching tags/pairs

Looking for a setting or an extension preferably in VSCode to highlight blade syntax.
For e.g. I'd like to find the #endif for an #if statement in a large blade file or the #endforeach for the #foreach loop etc.
See here how the opening HTML tag is highlighted with the closing one:
I've been looking around but have not found anything.
For HTML opening and closing tags
Use Highlight Matching Tag
For Blade directives
The ultimate solution that I've found is installing Blade Syntax for PHP and Blade Color extensions which are developed by the same person.
But it didn't work for me as shown on its preview.
The project seems to be abandoned for now since the last update was in June 2021 ...
However a good theme with proper formatting can save the day:
Solarized Dark
Tomorrow Night Blue
Monokai Dimmed
Destroy your eyes

Accessing source filename in sphinx/restructured text

I would like to add the following line to my conf.py file for Sphinx documentation, which apparently is valid for nbsphinx but isn't working for Sphinx 4.0.2.
rst_epilog = r"""
{% set docname = env.doc2path(env.docname, base=None) %}
.. tip:: this is {{ docname }}
"""
Update
Based upon suggestions made in the comments, I have reviewed this blog entry describing integration of Rst and Jinja in Sphinx and attempted to incorporate this tutorial information about creating a custom extension.
My approach was to follow the tutorial for including directories and modifying conf.py while using the module verbatim from the blog for my extension.
Ultimately, my desired use is still not functioning properly. I can confirm that Sphinx knows of my extension by including typos in the module (which causes make to fail) or by changing the extension to do nothing (i.e. commenting out the last line of the rstjinja function, so the extension does nothing except burn CPU cycles).

p5js with Jekyll

I am quite new to Jekyll and I am not sure how I can go about creating a website with p5.js sketches embedded into it for a project that I am working on.
I suspect it has something to do with dependencies and I would much appreciate any help/pointers I can get!
There is nothing special about the combination of Jekyll and P5.js.
The important thing to understand is that the output of Jekyll is "just" regular HTML. You can include a P5.js sketch inside any HTML page. So you can include P5.js in Jekyll just fine.
Here is an example page that embeds a P5.js sketch in a website created using Jekyll. Here is the source markdown of that page. Jekyll takes that markdown and outputs HTML.
It's going to be hard to be more specific than that, but the general answer to your question is to focus on the HTML and focus on any errors you're getting.
If you still can't get it figured out, please post new question that includes a link to an example Jekyll repo that shows the error, and include the full error in your post.
I wondered the same and #Kevin Workman's examples worked. Note that you don't need to add the entire javascript code in a script object, you can point to it (I for one didn't know any of this until an hour ago)
You can add something like this in your post's .md file to reference a file called "myjavascriptfile.js". Note you can also use a hosted version of the p5.js file
<div id="sketch-holder"></div>
<script src="https://cdn.jsdelivr.net/npm/p5#1.1.9/lib/p5.js"></script>
<script src="myjavascriptfile.js"></script>
The "sketch-holder" thing gives you a bit more control over the sketch and requires you to add this to the setup() function:
function setup() {
....
const canvas = createCanvas(something, something)
canvas.parent('sketch-holder')
....
}

Removing the Edit on Github link when using Read The Docs & Sphinx with ReadTheDocs Theme

I'm trying to find out how to use the _template overrides option in Sphinx to override the default ReadTheDocs theme for hosting Sphinx documentation on http://readthedocs.org.
Specifically, I'm wanting to remove/hide the "Edit on Github" link shown in the upper right hand corner of this theme.
Any tips would be greatly appreciated! Thanks!
I've reviewed the documentation here: http://www.sphinx-doc.org/en/stable/templating.html, however, I'm stumped and really need some help.
Thank you!
Okay, I figured it out so I'll answer my own inquiry in hopes to assist others.
Assuming you're using the ReadTheDocs default theme this should work just fine.
Clone the ReadTheDocs theme from the Github repo to your computer. (https://github.com/snide/sphinx_rtd_theme/)
Locate breadcrumbs.html file (https://github.com/snide/sphinx_rtd_theme/blob/master/sphinx_rtd_theme/breadcrumbs.html)
Add breadcrumbs.html file to your Sphinx documentation folder in the _templates folder. If this directory doesn't yet exist you'll need to create it.
In your conf.py file locate your html_context section, if you do not already have this, you can create it. (Sample linked below).
html_context = {
"display_github": False, # Add 'Edit on Github' link instead of 'View page source'
"last_updated": True,
"commit": False,
}
Add the breadcrumbs.html file to your tracked files using Git
Commit the changes to your conf.py
Push to remote Github repo
Profit
References
https://github.com/duelingdogs/dueling-docs/blob/master/source/conf.py#L36-L40
http://help.duelingdogs.net/en/latest/ (Example showing that the Edit on Github option is now removed.
The Read the Docs documentation has similar instructions: https://docs.readthedocs.io/en/latest/guides/remove-edit-buttons.html#. So perhaps there've been underlying code changes since the original answer was posted.
My needs was very similar but not exactly the same. I wanted to both remove this link for generated pages ("search" and "genindex"), and change the link text because we use framagit as a project hosting.
Here is my version at the end:
{%- extends "sphinx_rtd_theme/breadcrumbs.html" %}
{% block breadcrumbs_aside %}
<li class="wy-breadcrumbs-aside">
{% if hasdoc(pagename) and pagename != "search" and pagename != "genindex" %}
{{ _('Edit on FramaGit') }}
{% endif %}
</li>
{% endblock %}
See it live here:
https://framagit.org/simgrid/simgrid/tree/master/docs/source

In Jekyll, how does include_relative work with respect to layout files?

I have a file called default.html in my layouts folder. In default.html, I want to add a relative include to test.html, which is also in my layouts folder.
I add {% include_relative test.html }% in my default.html file to include test.html. However, when I do this, I get an error that says
"Liquid Exception: Included file './test.html' not found in
projects/[projectnmae]/layouts/default.html"
I do have my layouts folder in a different location, as specified in my configuration file. Any ideas if include_relative works in a special way here that I'm not grasping?
You can't use the include_relative tag with any files inside your layouts folder. You can only use include_relative on a page or post.
Layouts code is executed in the context of page/post rendering and the include_relative is calculated relative to this page or post, not from the layout itself.
Tracking this error in debugger shows that include_relative tries to load /home/user/www/test/_posts/test.html and not /home/user/www/test/_layouts/test.html

Resources