Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7519809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:57:49+00:00 2026-05-30T01:57:49+00:00

If I have markdown like this: # A Header “` javascript $(document).ready(function() {}) “`

  • 0

If I have markdown like this:

# A Header

``` javascript
$(document).ready(function() {})
```

It will render out like this:

<h1>A Header</h1>

<pre><code class="javascript">$(document).ready(function() {})</code></pre>

The issue is, I want to have those triple-backslash code blocks compile to HTML when they are wrapped in a div, so the markdown would look like this:

# A Header

<div class="row">
<div class="span6">
``` javascript
$(document).ready(function() {})
```
</div>
</div>

This way I can take advantage of both markdown and twitter bootstrap, for example.

But when I do that, the code block is never processed. Is there any way to accomplish without getting too deep into writing HTML parsing code?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:57:50+00:00Added an answer on May 30, 2026 at 1:57 am

    Per the Markdown spec (such as it is):

    Markdown formatting syntax is not processed within block-level HTML tags. E.g., you can’t use Markdown-style *emphasis* inside an HTML block.

    There’s a feature request on the Redcarpet GitHub page but unfortunately there’s no conclusion that will help you.

    Probably the path of least resistance here would be to run it through Redcarpet, then run the resulting HTML through Nokogiri, running the contents of each of its block-level nodes through Redcarpet again. E.g.:

    require 'redcarpet'
    require 'nokogiri'
    
    block_nodes = %w(p div blockquote ...) #¹
    
    markdown = Redcarpet::Markdown.new Redcarpet::Render::HTML,
                 :fenced_code_blocks => true
    
    html = markdown.render text
    
    noko_doc = Nokogiri::HTML::DocumentFragment.parse html
    
    noko_doc.css( *block_nodes ).each do |node|
      node.content = markdown.render node.content if node.text?
    end
    
    html = noko_doc.to_html
    

    ¹ https://github.com/tanoku/sundown/blob/master/html_block_names.txt

    Of course if, if you have more than one level of nesting (an HTML block containing a Markdown block containing an HTML block and so on) you’ll have to do this recursively on any new HTML nodes you generate. This would be easy but obviously has performance implications, which is why I said “path of least resistance” and not “best solution in all cases.”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assume that I have some HTML code, like this (generated from Markdown or Textile
If any of you have ever used wmd markdown editor (which is like the
Let's say I have a string like this: ===== and I want to replace
I have a Rails site, where the content is written in markdown. I wish
Is there a good Markdown editor for Dojo ? I have seen Control.TextArea (based
Have you guys had any experiences (positive or negative) by placing your source code/solution
Have a n-tire web application and search often times out after 30 secs. How
Have you managed to get Aptana Studio debugging to work? I tried following this,
I've just recently begun to use markdown and have noticed that any markdown within
How can I include a bookmarklet in a Markdown parsed document? Is there any

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.