Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pre's inside html #378

Closed
ianstormtaylor opened this issue Mar 28, 2014 · 4 comments
Closed

pre's inside html #378

ianstormtaylor opened this issue Mar 28, 2014 · 4 comments

Comments

@ianstormtaylor
Copy link
Contributor

Marked does an awesome thing where it lets you write markdown formatted strings inside HTML inside your markdown, so that you can for example make a <table> or <figure> and not have to resort to using <strong> or <em>. That is sweet.

Just ran into an issue though where <pre> tags aren't getting properly skipped for that inline formatting. Basically the check for whether to skip a block of HTML only checks the parent element, instead of nested <pre> tags, so an example like this will still have inline formatting applied:

My _markdown_ here...

<figure>
  <pre data-language="javascript"><code>
    Sample code that might contain things that _look_ like markdown.
  </code></pre>
  <pre data-language="ruby"><code>
    Sample code that might contain things that _look_ like markdown.
  </code></pre>
</figure>

More of my markdown down **here**.

In this case, since the top-level tag is <figure> Marked is still applying the inline formatters to the entire block, even though all of the <pre> children shouldn't have them applied.

@rymohr
Copy link

rymohr commented Dec 19, 2014

Just ran into this one too. @ianstormtaylor have you found a workaround yet? Doesn't seem like this one's being actively maintained anymore.

@rymohr
Copy link

rymohr commented Dec 19, 2014

I run into this even with something as simple as

<pre>![image](http://example.com/image.jpg)</pre>

More markdown.

The image gets processed into an <img> tag in this case.

@lindyblackburn
Copy link

If you can run javascript, you can set "marked.setOptions({pedantic: false});" to avoid marked breaking from the markdown spec and interpreting inside html blocks altogether.

Otherwise quick fix is to just use markdown (triple backticks, etc) inside the html blocks to set preformatted text or include *, etc.

@rymohr I think the html blocks need to be surrounded by blank lines.

@joshbruce
Copy link
Member

#983

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants