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

Include directives don't like being within blockquotes #1127

Open
carols10cents opened this issue Jan 16, 2020 · 1 comment
Open

Include directives don't like being within blockquotes #1127

carols10cents opened this issue Jan 16, 2020 · 1 comment
Labels
A-link-preprocessor Area: Link preprocessor, #{{include}}, etc.

Comments

@carols10cents
Copy link
Member

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 :(

@ehuss ehuss added the A-link-preprocessor Area: Link preprocessor, #{{include}}, etc. label Apr 21, 2020
@chriskrycho
Copy link

Much-delayed follow-up (after getting here via the source for TRPL): since #1003 landed, is this tractable? I ask jus tin case someone already knows off the top of their head; otherwise I will just poke at it and figure it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-link-preprocessor Area: Link preprocessor, #{{include}}, etc.
Projects
None yet
Development

No branches or pull requests

3 participants