Pygments: use an unknown/unsupported language - jekyll

I would like to use pygments for basic line-numbering only for files like krb.conf, Asterisk's extensions.conf or pam-configuration.
I use pygments via Jekyll.
{% highlight WHATOPUTHERE lineos %}
CODE CODE
{% endhighlight%}
However, I need to specify some language (otherwise nothing is produced). The same for unknown languages.
Software:
* Jekyll 0.11.2
* Pygments 1.6

There is a plain text language that you can use for situations where nothing else fits. I've just tested with the latest github-pages gem (uses Jekyl 1.4.3 and Pygments 0.5).
{% highlight text linenos %}
require 'yaml'
require 'rubygems'
require 'stringex'
{% endhighlight %}

Related

ignore a line in a markdown file with Jekyll

Is there a way to ignore a text line in a markdown document from the Jekyll engine?
On the main README.md, I have a link to my generated pages url ala,
View the [Docs as a Website](https://gitpages.mycompany.com/myrepo/) which links to our enterprise equivalent of github.io pages powered by Jekyll reading the /docs/ folder.
For obvious reasons, I would like to not show this on the pages site as the viewer is already there and it ends up in an endless loop if users were to keep clicking it.
Is there a way to have it show on the code-view readme.md but not on the rendered jekyll version?
Solution :
If you want Jekyll to skip processing lines (or even a single character) into the baked /_site/ output, use the Liquid {% comment %} tag:
{% comment %}
Character or lines for Jekyll to skip.
{% endcomment %}
Example :
Before:
Code w/o {% comment %} + HTML render
After:
Code w/ {% comment %} + HTML render
Explanation :
If a markdown.md page has Jekyll Front Matter at the top, then it will be processed by Jekyll into a markdown.html page (see Jekyll's docs for more info).
Pages processed by Jekyll can contain Liquid code (specifically Jekyll's implementation of Liquid).
Liquid features a {% comment %} tag. And it works for Jekyll.
From Liquid's documentation of the comment tag:
Comment
Allows you to leave un-rendered code inside a Liquid template. Any
text within the opening and closing comment blocks will not be
printed, and any Liquid code within will not be executed.
If Jekyll processes your markdown.md page, it will process all Liquid statements, and will totally omit the {% comment %} tag + {% endcomment %} tag + and everything in between from the output file.
The text wrapped by a {% comment %} tag does not specifically need to contain Liquid for Jekyll to exclude it. Everything inside will be omitted from the output page: e.g. <html> elements, other code, plaintext, etc.
Word of Caution :
Jekyll will still throw an error if you have improper Liquid syntax, even if it is inside a comment tag.
The following results in an error, and Jekyll will not build:
{% comment %}
Character or lines for Jekyll to skip.
{% assign abc
{% endcomment %}
To prevent this, either ensure (1) all the code inside your comment tag is valid Liquid, or (2) prevent Jekyll from evaluating the code by wrapping it inside a {% raw %} tag:
{% comment %}
{% raw %}
Character or lines for Jekyll to skip.
{% assign abc
{% endraw %}
{% endcomment %}
Then everything inside the comment will be successfully excluded from the /_site/ files Jekyll outputs.
For more information, see Liquid's documentation of the raw tag.
Alternatively:
If you just want to link from the site's GitHub repository -> to the site generated by Jekyll + GitHub Pages
Log in
Go to https://github.com/ user-or-org / repository-name
Click the "Edit" button (above "Clone or download" and below "Settings")
Add the URL to your GitHub Pages website in the 2nd text field that prompts "Website for this repository (optional)", and click "Save"
Remove the URL from your README.md

Import a static HTML website to Django CMS

I have designed and coded a website (with bootstrap 4) and now I would like to import it in Django CMS so the client can edit the content.
Any tips or guide that helps me to achieve this?
Thanks a lot
You have to make it into a template and import the information itself separately. Add new template to settings.py.
If your client already has a basic template that you're editing you may simply edit his existing files and CSS. Alternatively, you may also download/import an existing template and use it as your base for editing.
The template itself will look something like this: default template: base.html,
{% load i18n %}
{% extends 'base.html' %}
{% block title %}Title Here{% endblock %}
{% block content %}
{% endblock %}
#A-creative At first you should copy Bootstrap 4 static files (css and js) into your "projectname/appname/static" dir, run "python manage.py collectstatic" and then just copy your Bootstrap-ready html into the cms using Style, Text and Snippet plugin fields (Admin > Create new page > Edit > Add plugin/block > ...). You should do it page by page.
I doubt there is a shorter way... Yeap, and your should use a standard minimalistic template as mentioned by #Patriot to avoid dealing with template issues and plugin / html issues at the same time.

Jekyll, Github Pages: syntax highlighting not working

A similar question has been asked before but the solutions don't work for me.
I'm using Jekyll 3.3.0 with a Github Pages blog. According to the documentation, Jekyll supports code snippet highlighting natively as long as the _config.yml points to Kramdown for markdown processing and Rouge (I'm running 2.0.7) for syntax highlighting.
I can't get it to work using the approved method or various methods I've found on the internet. The only thing it recognises is that there is code there. For example, using either backticks or {% highlight html %} will remove this code and show my actual code, as expected. So it's recognising that it's a code snippet. But the highlighting doesn't work at all.
Here's my _config.yml:
baseurl: /blog
exclude: ['README.md']
permalink: pretty
# Conversion
markdown: kramdown
highlighter: rouge
kramdown:
input: GFM
hard_wrap: false
syntax_highlighter: rouge
extensions: fenced_code_blocks
And here's an example of a test I've tried in a .md:
```applescript
tell application "Safari" to quit
```
Applescript is supported by Rouge, so that shouldn't be the issue. Nevertheless, I have tested it with html:
```html
<a href="https://github.io>Here's a link to Github</a>
```
I've also tried:
{% highlight applescript %}
tell application "Safari" to quit
{% endhighlight %}
Github shows the highlighting when I view it through the github.com/user/repo but it breaks when viewed over user.github.io/repo
Thanks
The link address in _layouts/default.html was incomplete: it didn't include {{ site.baseurl }}
The full line should be:
<link href="{{ site.baseurl }}/css/syntax.css" rel="stylesheet">
As answered in this question: Add syntax highlighting to gh-pages , it was supposedly enough to use the correct markdown, as you've posted in your question. It was not working for me either, that's how I found this post.
I've added a syntax.css myself and are now using the lowercase name of the highlighted language that I need. Now it does work!

How to use Jekyll site.pages to generate sitemap.xml

I'm trying to use site.pages to automatically generate sitemap.xml in Jekyll (GitHub Pages), This is the sitemap.xml code I got:
---
---
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{% for page in site.pages %}
<url>
<loc>https://example.com{{ page.url | remove: 'index.html' }}</loc>
</url>
{% endfor %}
</urlset>
It's output is something similar to this:
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.com/samplepage.html</loc>
<!--<loc>https://example.com/samplepage</loc>-->
</url>
</urlset>
My goal is to generate a sitemap.xml without the trailing .html as in the commented line. I've tried gsub (I assumed Jekyll takes Ruby syntax: Replace words in string - ruby) but it seems either doesn't change anything or remove page.url completely.
I'd appreciate if anyone can
modify the Jekyll syntax so that it generates URLs without the trailing .html.
explain the syntax of | remove: 'index.html' (which removes the URL https://example.com/index.html from the generated sitemap.xml).
I'm very unfamiliar with Jekyll so apologies if the question seems trivial.
Jekyll uses Liquid to process templates. The pipe syntax is a Liquid filter:
Filters are simple methods. The first parameter is always the output of the left side of the filter. The return value of the filter will be the new left value when the next filter is run. When there are no more filters, the template will receive the resulting string.
remove is one of the standard Liquid filters, so the Jekyll documentation does not list it.
If you have this file in your root folder, the page URL is straightforward:
samplepage.html # https://example.com/samplepage.html
Instead, if you have:
samplepage/
index.html # https://example.com/samplepage/index.html
# https://example.com/samplepage/
The page URL ends up being the folder name, and the server will automatically serve the index.html file inside if you use the second link.
site.pages will give you the first link. As you have a filter that removes index.html from your paths, you end up with extension-free URLs.
Any file in Jekyll folder is generated with his extension, except if you use permalink.
If you create a sitemap.xml file like this :
---
layout: null
---
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{% for page in site.pages %}
<url>
<loc>https://example.com{{ page.url | remove: 'index.html' }}</loc>
</url>
{% endfor %}
</urlset>
It will be generated as sitemap.xml.
You can also use jekyll-sitemap wich is supported by github pages.

Can jekyll use GET parameters?

I would like to make a categories page.
{% for post in site.categories[CATEGORY_NAME] %}
<li>{{ post.title }} ({{post.date|date:"%-d %B %Y"}})</li>
{% endfor %}
Is it possible to use a page parameter to fill in CATEGORY_NAME? Then I could have one file category.html which could serve as the index page for multiple categories (i.e. category.html?name=food and category.html?name=animals.
I've found a few plugins that handle this, but it seems like overkill to require a plugin.
https://github.com/zroger/jekyll-categories
http://blog.nitrous.io/2013/08/30/using-jekyll-plugins-on-github-pages.html
Here's the most related forum post I could find.
https://groups.google.com/forum/#!topic/jekyll-rb/y-dq-63Uvy4
If I can't do this without a plug in, is there a good reason?
I think the correct answer is that Jekyll pages must be compiled to html before they are served. This is not possible if the liquid language takes a parameter.