Skip to content

Include directives don't like being within blockquotes  #1127

Open
@carols10cents

Description

@carols10cents

I'm using mdbook v0.3.5.

Here's the markdown I tried to write:

## Blockquote with included code inside

Lorum ipsum dolor sit amet.

> But do included code blocks...?
>
> ```rust
> {{#include another-included-test.rs}}
> ```
>
> By Quote Author

And here's the HTML I get when doing mdbook build, note the multiple <blockquote>s (I'd expect only one opening and one closing):

<h2><a class="header" href="#blockquote-with-included-code-inside" id="blockquote-with-included-code-inside">Blockquote with included code inside</a></h2>
<p>Lorum ipsum dolor sit amet.</p>
<blockquote>
<p>But do included code blocks...?</p>
<pre><pre class="playpen"><code class="language-rust">fn main() {
</code></pre></pre>
</blockquote>
<pre><code>println!(&quot;This is a file!&quot;);
</code></pre>
<p>}</p>
<blockquote>
<pre><code>
By Quote Author
</code></pre>
</blockquote>

And a screenshot of this:

Screen Shot of unexpected rendered HTML

If I use the markdown renderer instead, I see that after processing the include, the markdown looks like this:

## Blockquote with included code inside

Lorum ipsum dolor sit amet.

> But do included code blocks...?
>
> ```rust
> fn main() {
    println!("This is a file!");
}
> ```
>
> By Quote Author

but the markdown that needs to be generated is this:

## Blockquote with included code inside

Lorum ipsum dolor sit amet.

> But do included code blocks...?
>
> ```rust
> fn main() {
>     println!("This is a file!");
> }
> ```
>
> By Quote Author

I was going to try to fix this by taking whatever text appears on the same line before the include directive (so in this case > ) and then repeating that text before each line of the included file, but tests like this one show that inline includes are supported (that example would mean "Some random text with " would be prepended to every included line :().

Limiting the recognized text to something like only > would miss cases where there's a blockquote inside a blockquote or a blockquote inside a list or other edge cases I'm not thinking of.

So I don't know how to fix this, and I'm opening this to see if anyone else has ideas, or at least to document that this doesn't work :(

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-link-preprocessorArea: Link preprocessor, #{{include}}, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions