0

I've got the following Markdown code that gets parsed and displayed in HTML (the Markdown is being converted to HTML using RedCarpet):

curl https://api.example.com \
  -u "<span class='api_key'></span>:"

And I want the <span class='api_key'></span> to later be replaced with the acutal API key by Javascript.

The problem is that the code gets escaped (i.e. displayed as is), instead of getting evaluated.

The output of the previous code block is:

...
  -u "<span class='api_key'></span>:"

.. instead of the expected:

...
  -u ":"

How do I get around this?

FloatingRock
  • 6,741
  • 6
  • 42
  • 75
  • 1
    I don't know what "middleman" is, but in my blog, I parse Markdown using MarkdownExtra, and then run some preg_replace on it to do this post-processing (eg I added my own tags). So you could do it similar way, run regex on the output (or input) – MightyPork Jan 11 '15 at 12:40
  • Wasn't sure if I should add Middleman on there or not -- it just uses RedCarpet to convert the Markdown to HTML. Since this is HTML, i'm wondering if that can be done using Javascript? – FloatingRock Jan 11 '15 at 12:51
  • sure can, but if you are generating it on server side, it'd make more sense to do it there... – MightyPork Jan 11 '15 at 12:59
  • @MightyPork it's a static site.. so no backend action I'm afraid. Just HTML, CSS and good ole' JS – FloatingRock Jan 11 '15 at 13:04
  • really? I looked at the middleman tag and it seemed to be something from Ruby On Rails.. – MightyPork Jan 11 '15 at 13:05
  • @MightyPork well it's a Ruby tool that generates a static site. I'm using Javascript to send the API request, retrieve the API key, and replace all instances of `` with the returned API key. – FloatingRock Jan 11 '15 at 13:25

1 Answers1

2

You can use a plain .rb template instead of the .mdown template that you are currently using. That way, you can write custom HTML (and Ruby) in there without issue.