Markup: Conditional rendering for some filetypes (literate Haskell)

Created on 6 Apr 2015  ·  4Comments  ·  Source: github/markup

Following on from the discussion at #266 and a Reddit thread, I'd like to try getting literate Haskell rendering back into GitHub in an opt-in fashion. The goal is to only render .lhs files as markdown (via the literati library) _if_ they contain a specific HTML comment (<!-- literate-haskell: markdown -->). I figured on doing something like this:

markup(:literati, /lhs/) do |content|
  if content =~ /^<!--\s*literate-haskell:\s*markdown\s*-->/
    Literati.render(content)
  else
    content
  end
end

However, how will this interact with GitHub's content rendering? The goal is to have files completely unrendered if they do not contain the formatted comment.

Most helpful comment

How about .md.lhs, .rst.lhs, etc, for example?

All 4 comments

Currently a renderer is chosen based purely on filename, and if GitHub::Markup says it can render the file, then GitHub expects that rendered HTML will be returned. So any support for .lhs would have to always render something. We would be happy to consider a pull request for this, but I'll warn you that adding new markup formats is not currently a high priority.

Okay, thanks!

How about .md.lhs, .rst.lhs, etc, for example?

Would an extension like A.md.lhs confuse GHC? Would it still find the file? What would be the module name?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

daenney picture daenney  ·  3Comments

Alhadis picture Alhadis  ·  6Comments

kalkin picture kalkin  ·  3Comments

woodruffw picture woodruffw  ·  6Comments

atomoton picture atomoton  ·  7Comments