Jekyll twists : from rdiscount to kramdown jekyll, pygments, kramdown, sublimetext, table editor

Pygments with line number

Use pygments with options, linenos, hl_lines, … check the pygment pygment formatter options.

% highlight ruby linenos=table hl_lines=7 %

But there a bug when you use the table option with lineos, have to investigate …

 1     class Project < ActiveRecord::Base
 2       belongs_to :user
 3       belongs_to :owner, :class_name => 'User', :foreign_key => 'owner_id'
 4     end
 5 
 6     class User < ActiveRecord::Base
 7       authenticates_with_sorcery!
 8      
 9       validates :password,                presence: true, confirmation: true, length: { minimum: 3}, :if => :password
10       validates :email,                   presence: true, uniqueness: true
11       validates :password_confirmation,   presence: true, :if => :password
12       validates :username,                presence: true
13 
14       has_many :projects 
15       has_many :owners, :class_name => 'Project', :foreign_key => 'owner_id'
16     end

Hacking Jekyll : allow multiple line highlight

In Jekyll files, change the regexp syntax for allowing passing multiple parameters :

File jekyll/lib/jekyll/tags/highlight.rb change from :

 5        
 6     # The regular expression syntax checker. Start with the language specifier.
 7     # Follow that by zero or more space separated options that take one of two
 8     # forms:
 9     #
10     # 1. name
11     # 2. name=value
12     SYNTAX = /^([a-zA-Z0-9.+#-]+)((\s+\w+(=\w+)?)*)$/
13 
14     ...
15 
16     # line 29 :
17       @options[key] = value
18     

to :

 5        
 6     # The regular expression syntax checker. Start with the language specifier.
 7     # Follow that by zero or more space separated options that take one of two
 8     # forms:
 9     #
10     # 1. name
11     #     linenos
12     # 2. name=value
13     #     linenos=table linenostart=56
14     # 3. name=value1,value2,value3 
15     #     hl_lines=2,7 linenos linenostart=56
16     SYNTAX = /^([a-zA-Z0-9.+#-]+)((\s+\w+(=\w+(,\w+)*)?)*)$/
17 
18     ...
19 
20     # line 29 :
21       @options[key] = value.gsub(',',' ')
22     

Some kramdown config

Change in _config.yml :

markdown: kramdown
...
kramdown:
  auto_ids: true
  footnote_nr: 1
  entity_output: as_char
  toc_levels: 1..6
  use_coderay: false
  parse_block_html: true

What I had to change :

The Table of Content work easily with just : (and with some css adjustment)

* toc
{:toc} 

And use of some inline attributes like :

This is *red*{: style="color: red"}.

**This is a test**
{: style="text-align: center"}

Title
===
{: .big .thin}

And for some pages, I had to declare inner markdown usage in html block ie :

{::options parse_block_html="true" /}
<div>
  test **test**
</div>

Nota : some ordered list doesn’t seems to work :

I. one II. two III. three

a. aa b. bb c. cc

Sublime Text : Table Editor

A very good plugin for ST2 : https://github.com/vkocubinsky/SublimeTableEditor, work well with kramdown.


comments powered by Disqus