EzDevInfo.com

kramdown

kramdown is a fast, pure Ruby Markdown superset converter, using a strict syntax definition and supporting several common extensions. Home | kramdown kramdown is a fast, pure-ruby markdown-superset converter

Jekyll kramdown how to display table border

I am using Jekyll default kramdown. I have a table showed using

surround text, etc.

| Tables        | Are           | Cool  |
| ------------- |:-------------:| -----:|
| col 3 is      | right-aligned | $1600 |
| col 2 is      | centered      |   $12 |
| zebra stripes | are neat      |    $1 |

surround text...

But the table does not have border. How to show the border.
Thanks


Source: (StackOverflow)

How to highlight Markdown code in Jekyll?

I want to highlight markdown code in jekyll but I can't find a way how to do it. I looked at Pygement's lexers but I did not found one for markdown or kramdown.

I can highlight other codes but not markdown and kramdawn.


Source: (StackOverflow)

Advertisements

How do I turn off smart quotes in Jekyll?

How do I turn off smart quotes and apostrophes in Jekyll? It is breaking my gulp spellcheck process.

I want words like doesn't to stay with a single straight quote. Instead Jekyll is converting them to smart quotes like doesnt’ and I need them to stay single quoted for spell checking.

This is what I tried in my _config.yml:

kramdown:
    smartquotes:  ["apos", "rsquo", "ldquo", "rdquo"]

I'm using kramdown.

Here is my whole config:

name: Bitcoin Bulls
markdown: kramdown
timezone: America/Detroit
highlighter: pygments
author: David Smith
safe: true
lsi: false
permalink: none

url: http://www.bitcoinbulls.net
exclude:  [CNAME, Gemfile, Gemfile.lock, '*.less', gruntfile.js, custom_css, node_modules, README.md, '*.svg', '*.docx']
include: [glyphicons-halflings-regular.svg]


kramdown:
    smart_quotes: ["rdquo", "rsquo", "ldquo", "rdquo"]


relative_permalinks: false

defaults:
  -
    scope:
      path: "" # empty string for all files
    values:
      layout: "default"
  -
    scope:
      path: "" # empty string for all files
      type: post
    values:
      layout: "post"
      is_post: true

Source: (StackOverflow)

Escaping double curly braces inside a markdown code block in Jekyll

I'm using Jekyll to create a documentation site wherein I am trying to document some code that contains handlebars-like syntax. For example {{foo}}. The problem is that Jekyll uses liquid tags and no matter what I do, my double curlies are getting ripped out by the liquid processor.

By the way, I'm using kramdown as the markdown processor.

Here is something I've tried:

{% highlight html linenos %}
  Hello, my name is {{name}}.
{% endhighlight %}

This one removes the {{name}} section completely because it thinks it's a reference to a liquid variable.

I also tried this:

{% highlight html linenos %}
  Hello, my name is \{\{name\}\}.
{% endhighlight %}

In this case, I'm trying to escape the curly braces but the result is that the slashes get rendered into the page.

I even tried this:

{% highlight html linenos %}
  Hello, my name is <span>{</span>{name}}.
{% endhighlight %}

Admittedly this one was pretty dumb. In this case, because I've specified the syntax as html (which it needs to be), the span tag gets rendered into the page.

So how in the world can I resolve this?


Source: (StackOverflow)

Kramdown doesn't seem to render checkboxes like in GitHub

It seems Kramdown can recognise Github Flavoured Markdown in Jekyll. But it seems checkboxes that are available in GitHub isn't getting rendered using Kramdown, any ideas why?

What I am trying to do:

- [ ] Unchecked
- [x] Checked

This would show up as disabled checkboxes in GitHub but not so in Jekyll.


Source: (StackOverflow)

How do I prevent Kramdown from getting confused by a C++ include?

I have written this plugin:

module Jekyll
    module Tags
        class Prism < Liquid::Block
            def initialize(tag_name, text, tokens)
                @arg = text.strip
                super
            end

            def render(context)
                output = super(context)
                "<pre><code class=\"language-#{@arg}\">#{output}</code></pre>"
            end
        end
    end
end 

Liquid::Template.register_tag('prism', Jekyll::Tags::Prism)

This is how I use it:

{% prism cpp %}
#include <iostream>

// Hello World
int main()
{
    cout << "hello world" << endl;
    int a = 10;
}
{% endprism %}

Now, the problem is, that I mostly use C++ Code on my website. When I now generate this markdown with Jekyll, then all text after {% endprism %} would still be within the <pre> Tag, because Kramdown is getting confused by <iostream> If I escape it, (\<iostream\>), then my plugin works as expected, but my Javascript Highlighter is getting confused.

How can I solve this situation without enabling Jekyll's highlighter?


Source: (StackOverflow)

Render span-level string using Kramdown

I know that I can parse and render an HTML document with Kramdown in ruby using something like

require 'kramdown'

s = 'This is a _document_'
Kramdown::Document.new(s).to_html
# '<p>This is a <i>document</i></p>'

In this case, the string s may contain a full document in markdown syntax.

What I want to do, however, is to parse s assuming that it only contains span-level markdown syntax, and obtain the rendered html. In particular there should be no <p>, <blockquote>, or, e.g., <table> in the rendered html.

s = 'This is **only** a span-level string'
# .. ??? ...
# 'This is <b>only</b> a span-level string'

How can I do this?


Source: (StackOverflow)

Is it possible to generate a table of contents using kramdown in a page other than a post? If so, how?

The index page on my Jekyll site is meant to be exactly like a post with only one extra bit of code for navigating the other posts. I'm not really using it to generate a blog per se, but a bunch of press pages.

Now within each post I am using kramdown to generate a table of contents like so:

* This line is a placeholder to generate the table of contents
{:toc}

That works fine for all the posts, but when I try to use it on anything but a post, it doesn't generate. The output is simply empty. It doesn't show the raw kramdown above or anything, it just disappears and nothing (especially not a TOC) appears in it's place.

Some of the comments on this post: How to add a table of contents to Jekyll blog post?

Suggest putting a <li> before the above code, but I tried every possible iteration of that and it didn't work. Another comment suggested something with an <h1> tag is necessary, which exists.

I realize there's a plugin to generate a table of contents, the non-javascript version is older than the implementation of TOC using kramdown from what I've seen (that plugin is here: https://github.com/dafi/jekyll-toc-generator ).

And the other plugin ( https://github.com/ghiculescu/jekyll-table-of-contents ) is a bit more recent, but I would prefer not to use javascript to do what kramdown already can do.

Is it possible to use the standard kramdown table of contents markdown to generate one in my case on a page instead of a post?


Source: (StackOverflow)

Is it possible to change kramdown’s use of “↩” for footnote backlinks?

Kramdown uses “↩” (U+21A9) to link from footnotes back to the main text. Under OS X 10.10.3 and iOS 8.3, though, this character appears in Emoji form (↩️, if your browser supports it). Like John Gruber, I’d like to replace the bare U+21A9 with the two-character sequence U+21A9 U+FE0E, which will force it to render in “text style”. (That’s what I did in the title and the first sentence of this question.)

I don’t see a kramdown configuration option to change this character. Is it possible to change this in kramdown itself, or do I need to futz around manually with kramdown’s output?

If your browser doesn't show the Emoji, here's a screenshot:

enter image description here


Source: (StackOverflow)

writing posts in markdown inside html-div (with zurb foundation 5 and jekyll)

i am trying to create a blog with jekyll and zurb foundation 5. therefore id like to use some of the html structure of the foundation framework inside the posts, the post content indeed is written in markdown.

<div class="row">
  <div class="small-3 columns">

     ### Header of List

    - Item 1
    - Item 2
    - Item 3

  </div>
  <div class="small-9 columns">...</div> 
</div>

The markdown list works right but not the divs. the closing tags of the divs get translated raw als plane text to "".

how can i use markdown properly inside a div structure?

thanks for your help!


Source: (StackOverflow)

Make kramdown's ALDs available on entire Jekyll site

I'm using Jekyll to make a site that makes frequent use of kramdown's attribute list definitions. However the only way I can make this work right now is to include all of the definitions in every page e.g.

{:def1: ...}
{:def2: ...}
{:def3: ...}

This seems really smelly to me since if I want to change a definition, I need to do so in every single page. Ugh.

Is it possible to put these definitions somewhere where they will be included in every page? I tried putting them in a layout but it seems that Jekyll won't parse markdown in layouts.

I'm also open to alternatives to ALDs if this is not the right way to go about things.


Source: (StackOverflow)

Common Markdown Code Syntax for Kramdown

Is there any way to modify Kramdown through configuration options which will allow me to use Common Markdown/GFM fenced code block syntax, i.e.

```
here's the code!
```

I'm switching to Kramdown for my blog so I can have Markdown inside other elements, but most of my blog uses GFM for this, and it's how I normally write code in Markdown so it'd be cool if there was some way to do it.


Source: (StackOverflow)

Error when trying to inherit from ActionView::Template::Handler in Rails 3.2.13

I tried upgrading from Rails 3.0.23 to 3.2.13 and now I have an error stopping the server from starting that looks like this:

/Users/hamiltonchapman/Projects/project-static/lib/markdown_handler.rb:3:in `<top (required)>': uninitialized constant ActionView::Template::Handler (NameError)
  from /Users/hamiltonchapman/Projects/project-static/config/environment.rb:9:in `<top (required)>'
  from /Users/hamiltonchapman/Projects/project-static/config.ru:5:in `require'
  from /Users/hamiltonchapman/Projects/project-static/config.ru:5:in `block in <main>'
  from /Users/hamiltonchapman/.rvm/gems/ruby-2.1.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
  from /Users/hamiltonchapman/.rvm/gems/ruby-2.1.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
  from /Users/hamiltonchapman/Projects/project-static/config.ru:in `new'
  from /Users/hamiltonchapman/Projects/project-static/config.ru:in `<main>'
  from /Users/hamiltonchapman/.rvm/gems/ruby-2.1.1/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval'
  from /Users/hamiltonchapman/.rvm/gems/ruby-2.1.1/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file'
  from /Users/hamiltonchapman/.rvm/gems/ruby-2.1.1/gems/rack-1.4.5/lib/rack/server.rb:200:in `app'
  from /Users/hamiltonchapman/.rvm/gems/ruby-2.1.1/gems/railties-3.2.13/lib/rails/commands/server.rb:46:in `app'
  from /Users/hamiltonchapman/.rvm/gems/ruby-2.1.1/gems/rack-1.4.5/lib/rack/server.rb:304:in `wrapped_app'
  from /Users/hamiltonchapman/.rvm/gems/ruby-2.1.1/gems/rack-1.4.5/lib/rack/server.rb:254:in `start'
  from /Users/hamiltonchapman/.rvm/gems/ruby-2.1.1/gems/railties-3.2.13/lib/rails/commands/server.rb:70:in `start'
  from /Users/hamiltonchapman/.rvm/gems/ruby-2.1.1/gems/railties-3.2.13/lib/rails/commands.rb:55:in `block in <top (required)>'
  from /Users/hamiltonchapman/.rvm/gems/ruby-2.1.1/gems/railties-3.2.13/lib/rails/commands.rb:50:in `tap'
  from /Users/hamiltonchapman/.rvm/gems/ruby-2.1.1/gems/railties-3.2.13/lib/rails/commands.rb:50:in `<top (required)>'
  from script/rails:9:in `require'
  from script/rails:9:in `<main>'

The code that is causing this looks like:

require 'kramdown'

class MarkdownHandler < ActionView::Template::Handler
  def self.call(template)
    new.render(template, nil)
  end

  def render(template, local_assigns)
    %(Kramdown::Document.new(
      ERB.new(#{template.source.inspect}).result(binding)
    ).to_html.html_safe)
  end
end

ActionView::Template.register_template_handler :emd, MarkdownHandler
ActionView::Template.register_template_handler :md, MarkdownHandler

However, if I just remove the inheritance then the server starts fine and all of the markdown files render as expected.

Any ideas as to what's going wrong?


Source: (StackOverflow)

Php code highlight in Jekyll kramdown don't work

I'm using Jekyll with kramdown and pygments, it work fine for javascript or python code but When I create php like:

{% highlight php %}
header('Content-Type: application/json');

echo json_encode(array(
    'jsonrpc' => "2.0",
    'result' => $result,
    'id' => $request->id,
    'error' => null
));
{% endhighlight %}

Each line is one span with x class:

<code class="language-php" data-lang="php"><span class="x">header('Content-Type: application/json');</span>
<span class="x">echo json_encode(array(</span>
<span class="x">    'jsonrpc' =&gt; "2.0",</span>
<span class="x">    'result' =&gt; $result,</span>
<span class="x">    'id' =&gt; $request-&gt;id,</span>
<span class="x">    'error' =&gt; null</span>
<span class="x">));</span></code>

Why I don't have tokens with different classes for php code?


Source: (StackOverflow)

Missing Gem Dependencies

I am experiencing a problem with my build and missing a gem. However, I've installed the gem multiple times to no avail. I'm using NPM to manage packages as well. Since Jekyll is looking for kramdown, a gem, how can I let my build know it's installed locally?

Apologies on the weird question. I'm new to gems and stuff.

My error:

    Warning: Command failed: You are missing a library required for Markdown. Please run:
  $ [sudo] gem install kramdown
  Conversion error: There was an error converting 'project/adrian-college.md'.
             ERROR: YOUR SITE COULD NOT BE BUILT:
                    ------------------------------------
                    Missing dependency: kramdown
 Use --force to continue.

SOLUTION

'gem install kramdown' installed the gem locally but wasn't included as a dependency for the project. I had to simply edit the Gemfile manually and add: gem 'kramdown' then run bundle install.


Source: (StackOverflow)