EzDevInfo.com

maruku

A pure-Ruby Markdown-superset interpreter (Official Repo).

pygments problems in jekyll

I use jekyll in github pages. http://juanpabloaj.github.com/

But, when I add the syntax.css file for pygments

 <link rel="stylesheet" rel='nofollow' href="/css/syntax.css" type="text/css" media="screen" /> 

default.html

jekyll don't show the syntax, I have set on the pygments line

 pygments:    true

pygments-true


Source: (StackOverflow)

Extending MaRuKu to generate raw html tags, md_html escapes html

I'm working in the Insitiki code and trying to extend the maruku syntax to generate some custom html tags.

Example:

|youtube 0FWPr6u8YF |

Should print the html code as follows:

<object data='http://www.youtube.com/v/01hcB2zmMqM' style='width:425px; height:350px;' type='application/x-shockwave-flash'><param name='movie' value='http://www.youtube.com/v/01hcB2zmMqM'/></object>

Thus giving me a youtube embbeded video.

To make it work I followed this tutorial http://maruku.rubyforge.org/extending/extensions.html and looked at maruku documentation.

THE PROBLEM is, using the maruku method:

context.push(doc.md_html("<p>raw html</p>"))

The resulting html code is escaped, so what I get is verbatim text and not the raw html that I wanted.

I tried changing the strategy and using something like:

context.push(doc.md_el(:raw_html,[],:raw_html => "<p> raw raw raw </p>")

To no use ... what I get now is: REXML could not parse this XML/HTML:

Found nothing on this issue, the maruku docs are really thin (or I'm really bad at searching)... this guy seems to have a similar problem http://stackoverflow.com/questions/1973717/textile-and-maruku-problem

Any help is appreciated.


Source: (StackOverflow)

Advertisements

In jeykll, why latex can't be parsed when I name the post with sufix markdown but it works when with sufix html?

I am using the maruku markdown engine in jeykll, and when post a post, I use math code such as:

\begin{aligned} \dot{x} & = \sigma(y-x) \ \dot{y} & = \rho x - y - xz \ \dot{z} & = -\beta z + xy \end{aligned}

$ \dot{x} & = \sigma(y-x) \ \dot{y} & = \rho x - y - xz \
\dot{z} & = -\beta z + xy $

\( \dot{x} & = \sigma(y-x) \ \dot{y} & = \rho x - y - xz \
\dot{z} & = -\beta z + xy \)

\[ \dot{x} & = \sigma(y-x) \ \dot{y} & = \rho x - y - xz \
\dot{z} & = -\beta z + xy \]

if the post name is ended wiht markdown or md instead of html, only the first latex code can be parsed and transformed to a correct layout.

Why? How should I do so that I could name file with sufix .markdown and hanle the latex correctly?


Source: (StackOverflow)

Possible to disable markdown within html parsing?

I'm using jekyll/gh-pages. Both Maruku and RDiscount are getting very confused with the following code:

<figure>
    <a id="fig-14"></a>
    <pre><code>
hashA = entityA._roId + ':' + entityB._roId;
hashB = entityB._roId + ':' + entityA._roId;

if( !checked[hashA] && !checked[hashB] ){

    // mark this pair as checked
    checked[hashA] = checked[hashB] = true;

    if( this.aabb2DIntersection( entityA, entityB ) ){
        pairs.push( [entityA, entityB] );
    }
}
    </code></pre>
    <figcaption>
        Fig. 14: Keeping a cache of tested pairs.
    </figcaption>
</figure>

Maruku is just completely failing to parse the block, while RDiscount uses figure as an html tag, but then thinks that everything inside is code because it's indented. I'm assuming this is because of support for parsing markdown within html blocks.

In either RDiscount or Maruku, is there a way to disable parsing within html blocks?

EDIT::

It turns out the error, at least in Maruku, is my fault. & and < need to be escaped, even in <code> elements. So while I still don't have an answer to this actual SO question, I do have an answer as to why maruku was having trouble with the block.


Source: (StackOverflow)

Problems using Maruku in Rails 3

I am new to Rails but have used PHP extensively over the years. I am building a simple blog (I know) to get my skills up in the MVC/Rails world.

I have the basics working but have spent the weekend trying to get Maruku to work eg a post body saved from a text area with Markdown Extra markup to the db and then back again to the browser.

I used the following code in my Post model but I get an error when I try to load /posts - "undefined local variable or method `maruku' for #"

class Post < ActiveRecord::Base
validates :name,  :presence => true
validates :title, :presence => true,
                :length => { :minimum => 5 }
validates :content,  :presence => true
validates :excerpt,  :presence => true

has_many :comments, :dependent => :destroy

maruku.new(:content).to_html

end

I also tried something similar in my Posts Controller that I found on here. Then called @post.content in my Show view but get an error:

body = maruku.new(post.body)
post.body = body.to_html

I am dead sure it's my noob brain being dead but any help or direction would be great as I have fought with this for two days now. BTW I am using maruku as I need Markdown Extra as my old blog posts are all formatted that way.

Thanks

UPDATED - PostsController

class PostsController < ApplicationController

# GET /posts
# GET /posts.xml
def index
@posts = Post.find(:all, :order => 'created_at DESC')

respond_to do |format|
format.html # index.html.erb
format.xml  { render :xml => @posts }
end
end

# GET /posts/1
# GET /posts/1.xml
def show
@post = Post.find(params[:id])

respond_to do |format|
format.html # show.html.erb
format.xml  { render :xml => @post }
end
end

# GET /posts/new
# GET /posts/new.xml
def new
@post = Post.new

respond_to do |format|
format.html # new.html.erb
format.xml  { render :xml => @post }
end
end

# GET /posts/1/edit
def edit
@post = Post.find(params[:id])
end


# POST /posts
# POST /posts.xml
def create
@post = Post.new(params[:post])

respond_to do |format|
if @post.save
format.html { redirect_to(@post, :notice => 'Post was successfully created.') }
format.xml  { render :xml => @post, :status => :created, :location => @post }
else
format.html { render :action => "new" }
format.xml  { render :xml => @post.errors, :status => :unprocessable_entity }
end
end
end

# PUT /posts/1
# PUT /posts/1.xml
def update
@post = Post.find(params[:id])

respond_to do |format|
if @post.update_attributes(params[:post])
format.html { redirect_to(@post, :notice => 'Post was successfully updated.') }
format.xml  { head :ok }
else
format.html { render :action => "edit" }
format.xml  { render :xml => @post.errors, :status => :unprocessable_entity }
end
end
end

# DELETE /posts/1
# DELETE /posts/1.xml
def destroy
@post = Post.find(params[:id])
@post.destroy

respond_to do |format|
format.html { redirect_to(posts_url) }
format.xml  { head :ok }
end
end
end

Source: (StackOverflow)

Unable to run jekyll

I use Github pages to host my websites,I have test it on my local machine, and it works well, but when I push my sites on Github, I got an error. It says

The page build failed with the following error:

unable to run jekyll

My _config.yml file

---
auto        : false
lsi         : false
pygments    : true
permalink   : none
markdown    : maruku

maruku:
    use_divs:   true 
    use_tex:  true 
    png_engine : blahtex
    png_dir    : images/latex/
    png_url    : /images/latex/

I have searched the web, but can't find any useful ideas. Who can help me?

I have resorted to Github, they sent me the log, here is the error: Maruku: Using extended syntax for div elements.\nMaruku: Using LaTeX extension. Images in images/latex/.\n/var/lib/gems/1.8/gems/maruku-0.6.0/lib/maruku/ext/math/mathml_engines/blahtex.rb:40:in convert_to_png_blahtex': Blahtex error: empty output (RuntimeError)\n\tfrom /var/lib/gems/1.8/gems/maruku-0.6.0/lib/maruku/ext/math/to_html.rb:64:insend'\n\tfrom /var/lib/gems/1.8/gems/maruku-0.6.0/lib/maruku/ext/math/to_html.rb:64:in render_png'\n\tfrom /var/lib/gems/1.8/gems/maruku-0.6.0/lib/maruku/ext/math/to_html.rb:120:into_html_equation'\n\tfrom /var/lib/gems/1.8/gems/maruku-0.6.0/lib/maruku/output/to_html.rb:970:in send'\n\tfrom /var/lib/gems/1.8/gems/maruku-0.6.0/lib/maruku/output/to_html.rb:970:inarray_to_html'\n\tfrom /var/lib/gems/1.8/gems/maruku-0.6.0/lib/maruku/output/to_html.rb:961:in each'\n\tfrom /var/lib/gems/1.8/gems/maruku-0.6.0/lib/maruku/output/to_html.rb:961:inarray_to_html'\n\tfrom /var/lib/gems/1.8/gems/maruku-0.6.0/lib/maruku/output/to_html.rb:956:in children_to_html'\n\tfrom /var/lib/gems/1.8/gems/maruku-0.6.0/lib/maruku/output/to_html.rb:50:into_html'\n\tfrom /var/lib/gems/1.8/gems/jekyll-0.11.0/bin/../lib/jekyll/converters/markdown.rb:120:in convert'\n\tfrom /var/lib/gems/1.8/gems/jekyll-0.11.0/bin/../lib/jekyll/convertible.rb:46:intransform'\n\tfrom /var/lib/gems/1.8/gems/jekyll-0.11.0/bin/../lib/jekyll/convertible.rb:84:in do_layout'\n\tfrom /var/lib/gems/1.8/gems/jekyll-0.11.0/bin/../lib/jekyll/post.rb:189:inrender'\n\tfrom /var/lib/gems/1.8/gems/jekyll-0.11.0/bin/../lib/jekyll/site.rb:193:in render'\n\tfrom /var/lib/gems/1.8/gems/jekyll-0.11.0/bin/../lib/jekyll/site.rb:192:ineach'\n\tfrom /var/lib/gems/1.8/gems/jekyll-0.11.0/bin/../lib/jekyll/site.rb:192:in render'\n\tfrom /var/lib/gems/1.8/gems/jekyll-0.11.0/bin/../lib/jekyll/site.rb:40:inprocess'\n\tfrom /var/lib/gems/1.8/gems/jekyll-0.11.0/bin/jekyll:250\n\tfrom /var/lib/gems/1.8/bin/jekyll:19:in `load'\n\tfrom /var/lib/gems/1.8/bin/jekyll:19\n"

From the log, We can see the problem is `convert_to_png_blahtex': Blahtex error: empty output (RuntimeError). I read the blahtex code,

if png.name != 'png'
   maruku_error "Blahtex error: \n#{doc}"
   return nil
end

But, png files are there. Anyone has encountered this problem?


Source: (StackOverflow)

LaTeX formulas to images conversion in Jekyll.rb

I'm creating a site using jekyll.rb.

When converting LaTeX equations to PNG images using Blahtex, Maruku stores the images in the "latex/images" directory. I have to manually copy this directory to "_site" directory for the equations to be displayed correctly. Is this normal behavior?

Here is my _config.yml file.

url: "http://localhost:4000"

paginate: 10

source:      .
destination: ./_site

markdown: maruku
pygments: true

maruku:
    use_tex : true
    use_divs : true
    png_engine : blahtex
    png_dir : images/latex/
    png_url : /images/latex/

Source: (StackOverflow)

Haml in Maruku Filter

For this project, I need to be able to mix Haml tags within the Maruku filter. For example, will I be able to do this:

#contain
  :maruku
    ## Hello H2 Tag
      div{:id => 'divinmaruku'}
        **Can I do this?**

I know you can just unindent where you want to get out Maruku, but it is a pain to do :maruku whenever I want to use it.


Source: (StackOverflow)

how to write code blocks using maruku

how can i write code blocks in maruku for ruby,javascript

currently i am using technique. but my first line moving to left.

hash["test"] = "test"
hash.merge!("test" => "test")
h=HashWithIndifferentAccess.new
h.update(:test => "test")

{:lang=ruby html_use_syntax=true}


Source: (StackOverflow)

textile and maruku problem

all. I've developed custom filters for HAML (http://github.com/alec-c4/cb-haml-filters) and have a small problem with textile and maruku. Maybe you can help me with this

  1. Problem with textile with code

      %h2 Textile test
      :cbtextile
        h4. YouTube video
         http://www.youtube.com/watch?v=0_IXrjqKbE4&feature=player_embedded
    

after parsing i see embeded youtube video inside h4 tag (there are 1 empty line between h4. and http://youtube... i mean \n\n). But on TWO empty lines (\n\n\n) - all renders correctly. In markdown - all html renders fine.

  1. Maruku. all is ok, but scribd filter causes error

    REXML could not parse this XML/HTML:


Source: (StackOverflow)

Maruku markdown deletes any html in list item

Simple example here.

Source:

<span> hello </span>

1. <span> world </span>

Target:

<span> hello </span>
<ol>
<li />
</ol>

Seems to happen no matter what tag I use. As far as I can tell from daring fireball's markdown documentation, this should be legal; span tags can appear anywhere. I am on Jekyll and do not know what layer is responsible for this (bug in Jekyll's markdown renderer, my not using markdown correctly, etc.) For good measure let's see what SO does with the same source:

hello

  1. world

Looks like SO renders correctly.

This does not affect redcarpet or kramdown and appears to be a bug in Maruku. Bug report submitted here: https://github.com/bhollis/maruku/issues/88

Leaving Jekyll tag as Maruku is the default markdown processor for Jekyll, and that's how I found this.


Source: (StackOverflow)

Maruku/Markdown syntax meaning "+--" "=--"

I came across some syntax in a raw Markdown file which I believe might be Maruku specific:

+--{.abstract}
### Abstract
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation 
ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur
sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id 
est laborum.
=--

I've searched around, but I can't find any documentation for the +--/=-- block. Has anyone seen this before and can point me to some documentation?


Source: (StackOverflow)

Maruku incorrectly parsing second line of code blocks?

I'm using Maruku (Ruby) to parse some Markdown formatted text. I have a problem when trying to format a block of code like such:

This is a normal line
# pretend this line is empty
    printf("First line of code is OK");
    printf("Second line of code (or any line thereafter) appears indented by an extra level, which is incorrect!");

So my first line of code (which I've indented in my md file by 4 spaces (or a tab), renders just as I'd expect. However, my second line of code (indented by exactly the same number of spaces) ends up being indented by an extra 4 spaces when the HTML is generated.

The output looks like this:

This is a normal line
<pre><code>printf("First line of code is OK");
      printf("Second line of code (or any line thereafter) appears indented by an extra level, which is incorrect!");</code></pre>

I've tested my Markdown input with Gruber's "Dingus", and it renders as I'd expect (that is, both lines of code in a single block, both indented at the same level). But with Maruku, it's bunk.

I've also tried with RDiscount, but I get the same effect. I'm using Maruku because I need definition lists.

How SO formats it:

This is a normal line

printf("First line of code is OK\n");
printf("Second line of code (or any line thereafter) appears indented by an extra level, which is incorrect!");

Source: (StackOverflow)

How do I tell Jekyll/Maruku which post has the Markdown syntax error?

How do I tell Jekyll/Maruku to tell me which file has my Mardown syntax error?

The build warning only tells me so much:

$ jekyll --safe

Configuration from /homne/me/_config.yml
Building site: /homne/me -> /homne/me/_site

 ___________________________________________________________________________
| Maruku tells you:
+---------------------------------------------------------------------------
| Could not find ref_id = "md_entityhellip" for md_link([md_entity("hellip")],"md_entityhellip")
| Available refs are ["png", "2", "3", "4", "5", "6"]
+---------------------------------------------------------------------------
!/home/eoin/.rvm/gems/ruby-1.9.3-p385/gems/maruku-0.6.1/lib/maruku/errors_management.rb:49:in `maruku_error'
!/home/eoin/.rvm/gems/ruby-1.9.3-p385/gems/maruku-0.6.1/lib/maruku/output/to_html.rb:716:in `to_html_link'
!/home/eoin/.rvm/gems/ruby-1.9.3-p385/gems/maruku-0.6.1/lib/maruku/output/to_html.rb:970:in `block in array_to_html'
!/home/eoin/.rvm/gems/ruby-1.9.3-p385/gems/maruku-0.6.1/lib/maruku/output/to_html.rb:961:in `each'
!/home/eoin/.rvm/gems/ruby-1.9.3-p385/gems/maruku-0.6.1/lib/maruku/output/to_html.rb:961:in `array_to_html'
\___________________________________________________________________________
Not creating a link for ref_id = "md_entityhellip".Successfully generated site: /homne/me -> /homne/me/_site

Source: (StackOverflow)

Jekyll documentation to PDF with TOC

I would like to write documentation using Jekyll with HTML and PDF outputs. Html can have a navigation but the PDF should have table of contents. Is there a free and easy way to do that?

The HTML part is easy but I would like to use @media print CSS for making the PDF file.

I have a few ideas how to do this.

  1. Use PrinceXML, unfortunately this is commercial product with a nasty price tag ~$500
  2. Use WKHTMLTOPDF
  3. Use Maruku, since it is possible to do a PDF conversion using it

I would like to have multiple pages HTML and single page PDF with a TOC. Any suggestions?

Btw. Buildr has solved this problem using PrinceXML.


Source: (StackOverflow)