0
votes

I'm working on a github-pages project with all the usual suspects. I'm trying to switch my markdown from kramdown to redcarpet to better support GFM for local development. I have an existing project that has just one troublesome section of markdown. It's a single-line code block with a variable name containing underscores.

```function_field_name```

_config.yml

markdown: redcarpet

redcarpet:
  extensions: ["tables", "autolink", "strikethrough", "space_after_headers", "with_toc_data",  "no_intra_emphasis", "fenced_code_blocks"]

highlighter: pygments
safe: true

I get the following error:

Conversion error: There was an error converting 'queries.md'. jekyll 2.2.0 | Error: Traceback (most recent call last): File "/Users/shawnjohnson/.rvm/gems/ruby-2.1.1/gems/pygments.rb-0.6.0/lib/pygments/mentos.py", line 303, in start res = self.get_data(method, lexer, args, kwargs, text) File "/Users/shawnjohnson/.rvm/gems/ruby-2.1.1/gems/pygments.rb-0.6.0/lib/pygments/mentos.py", line 171, in get_data res = self.highlight_text(text, lexer, formatter_name, args, _convert_keys(opts)) File "/Users/shawnjohnson/.rvm/gems/ruby-2.1.1/gems/pygments.rb-0.6.0/lib/pygments/mentos.py", line 122, in highlight_text lexer = self.return_lexer(lexer, args, kwargs, code) File "/Users/shawnjohnson/.rvm/gems/ruby-2.1.1/gems/pygments.rb-0.6.0/lib/pygments/mentos.py", line 79, in return_lexer return lexers.get_lexer_by_name(lexer, **inputs) File "/Users/shawnjohnson/.rvm/gems/ruby-2.1.1/gems/pygments.rb-0.6.0/vendor/pygments-main/pygments/lexers/init.py", line 98, in get_lexer_by_name raise ClassNotFound('no lexer for alias %r found' % _alias) ClassNotFound: no lexer for alias 'function_field_name```' found

2

2 Answers

1
votes

Your backticks must be positionned like this :

``` javascript
function_field_name
```

But with backtics you will have no highlighting. Prefer highlight tag

{% highlight javascript %}
function_field_name
{% endhighlight %}

Plus : if you want kramdown to be GFM complient just add this to _config.yml

markdown: kramdown

kramdown:
  # use Github Flavored Markdown
  input: GFM
  # do not replace newlines by <br>s
  hard_wrap: false
0
votes

I found what was going wrong, it is rather a stupid question (:

You see the log : ClassNotFound: no lexer for alias 'function_field_name```' found, where function_field_name``` is actually what you putted inside the highlighter syntax. You should put your desired language like javascript or others, instead of function_field_name```.

Pygments gave you the error message because there is no programming language called 'function_field_name``` . I am sure you just started with the pygments and you just copied the source code from somewhere else.

To make it even clear, you should use

{% highlight javascript %}
function_field_name
{% endhighlight %}

Not:

{% highlight function_field_name```  %}
function_field_name
{% function_field_name```  %}