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

Already on GitHub? Sign in to your account

support for nesting markup or ignoring other markup within code blocks #30

Closed
cordoval opened this Issue Oct 9, 2012 · 4 comments

Comments

Projects
None yet
2 participants

@cordoval cordoval referenced this issue in KnpLabs/KnpBundles Oct 9, 2012

Merged

[#232]Feature/sundown parser #273

Owner

chobie commented Oct 10, 2012

I guess custom render will solve your problem.

<?php

class NestedRender extends Sundown\Render\HTML
{
        public function blockCode($code, $language)
        {
                $sd = new \Sundown\Markdown($this,  array("autolink"=>true, "fenced_code_blocks"=>true));
                return "<pre><code lang='$language'>" . $sd->render($code) . "</code></pre>";
        }
}


$render = new NestedRender();
$md = new \Sundown\Markdown($render, array("autolink"=>true, "fenced_code_blocks"=>true));

$stringOfDeath = <<<EOD

// put some code blocks here.  github's issue can't display correctly

Testing inline markup for code ```triple tick text```
EOD;

echo $md->render($stringOfDeath);
<pre><code class='yaml'><h1>someLabel</h1>
<p>some code text</p>
</code></pre><p>Testing inline markup for code <code>triple tick text</code></p>

but render doesn't have a accessor for \Sundown\Markdown class. so I might add something to fetch it.

Contributor

cordoval commented Oct 10, 2012

i was talking about this part:

``` yaml
#someLabel
some code text
<p>``` yaml</p>
<h1>someLabel</h1>
<p>some code text
```</p>

whereas it should be:

<code>
someLabel
some code text
</code>
Owner

chobie commented Oct 10, 2012

did you set fenced_code_blocks extension to \Sundown\Markdown?

$sd = new \Sundown\Markdown($render,  array("fenced_code_blocks"=>true));

otherwise below output is correct.

<p>``` yaml</p>
<h1>someLabel</h1>
<p>some code text
```</p>
Contributor

cordoval commented Oct 10, 2012

found the problem thanks so much!

@cordoval cordoval closed this Oct 10, 2012

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