Text Plugin & Markdown Not Rendering GFM #403

Open
coreybutler opened this Issue Jan 20, 2013 · 3 comments

Projects

None yet

2 participants

@coreybutler

I'm not sure if this is a bug, enhancement request, or just sheer lack of understanding of docpad internals (I'm new to it, and new to coffeescript too). Anyhow...

I am importing a blog from Tumblr, which allows you to add <!-- more --> to your entry. The content written before this generates an article summary, which is what shows up on my list of blog entries. I intend to put small code snippets in these summaries (written as markdown). When I display the fully rendered page, it works as expected, generating GFM formatted code. However; the snippet only renders as regular markdown. Since I'm using the text plugin to render this, I suspect it is not using the marked plugin that the "full article" page is using... thus the difference.

For example, I have the following source as my "summary":



my file params


def test
push "something"
var x = 1;
console.log(x);

... rest of the content ...


Using the text plugin, it renders like:
ruby def test push "something"``js var x = 1; console.log(x)

Using the marked plugin, it renders like:

def test
push "something"
var x = 1+2;
console.log(x);

For completeness, here's the rest of the relevant bits in this operation:

In my docpad.coffee, I have a crude function to extract the summary:

getSummary: (page) ->
  if page.hasOwnProperty('summary')
    return page.summary
  c = page.body.indexOf('<!-- more -->')
  if c > 0
    return page.content.substring(0,c)
  page.content.substring(0,355)+'...'

And in my layout.html.md.eco, I use the following code within a loop of my article list:

<text render="html.md">
  <%- @getSummary(post) %>
</text>

I would expect my "summary" would render with GFM, not as plain markedown. So, I've arrived at the conclusion the text plugin has it's own markdown renderer? Again, I'm new to docpad, and hopefully this is an easy thing to fix. Perhaps someone could point me in the right direction? Is there a way to configure the text plugin use the marked plugin?


Using docpad@6.21.4.


Want to back this issue? Place a bounty on it! We accept bounties via Bountysource.

@coreybutler

I was exploring an unrelated issue and ended up changing my primary layout name from layout.html.md.eco to just layout.html.eco. Having done this, the markdown now renders as expected... so perhaps there was a conflict here. I'm going to leave this open though, because changing a file name should not affect this.

@balupton
Member

The text plugin just uses the docpad rendering process, so it would be strange that the output is different. Try the following: <text render="markdown"><%- @getSummary(post) %></text> as perhaps there is something wrong with the new lines, or something wrong with the extension rendering.

Another suggestion would be that your layout is layout.html.md.eco but we are rendering markdown content with the text plugin. If there is no markdown content in your layout, then your layout just needs to be layout.html.eco.

Can I get access to the source of this project? It would help with debugging what the issue is.

@coreybutler

Thanks @balupton - I stripped out the markdown in the template and renamed the file as suggested. This seems to have worked. For completeness, I will try your other suggestion as well (i.e. simply indicating markdown instead of html.md).

Currently the code is all on my local git repo... I'll try to get something setup so you can see the source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment