Paragraph break in LaTeX output
I'm writing a document that contains both the contents of a book and the slides to go with them. So I've turned off autoslides and use the slide directive. All is well in the HTML output but in the LaTeX output, if I have a structure like: paragraph1 - slide - paragraph2, when the slide gets removed in the builder the two paragraphs get merged into one. In the process_slide_nodes function in directives.py, I've changed the last line from
node.replace_self(nodes.inline())
to
node.replace_self(nodes.paragraph())
and the issue seems to be fixed. This makes more sense to me but I'm not sure whether it would break other use cases.
Replacing the slide node with a paragraph node is probably not a good idea because although it works with the LaTeX/PDF output, it generates an empty paragraph in the HTML output. Replacing it with a comment node seems to work in all outputs. So the last line becomes:
node.replace_self(nodes.comment())
But it feels like a hack rather than a proper solution.
Thanks for reporting this, @uyar. I suspect the interesting thing would be to figure out what the restructured text "tree" looks like when you have two consecutive paragraphs, as well as paragraphs with a slide in between them. That would give us some information about what the "right" thing to replace with might be. I think the xml or psuedoxml builders might be helpful here (ie, running make xml might give us that information). I won't be able to dig in until next week some time, at best, so if you come up with more context/info, please add it here!
Thanks again!
OK, the results of my tests are below. My source document goes like this:
para1
para2
.. slide:: Slide Title
:class: cover
slide text
para3
Using the original code in hieroglyph (the one that replaces slide nodes with inline in the builders that don't support slides like html, latex and xml), I get the following outputs:
For LaTeX:
para1
para2
\DUrole{cover}{}
para3
Note that there is no empty line from para2 to para3 which effectively makes all three lines into one paragraph. For HTML, there is an empty span but no visible problem:
<p>para1</p>
<p>para2</p>
<span class="cover"></span><p>para3</p>
And similarly for XML:
<paragraph>para1</paragraph>
<paragraph>para2</paragraph>
<inline classes="cover"></inline>
<paragraph>para3</paragraph>
Since I couldn't find a way to add an empty line, I tried replacing with a paragraph. For LaTeX, it works:
para1
para2
para3
But for HTML and XML it creates empty paragraphs:
<p>para1</p>
<p>para2</p>
<p class="cover"></p>
<p>para3</p>
<paragraph>para1</paragraph>
<paragraph>para2</paragraph>
<paragraph classes="cover"></paragraph>
<paragraph>para3</paragraph>
And here is what happens if I replace with comment nodes:
para1
para2
para3
<p>para1</p>
<p>para2</p>
<p>para3</p>
<paragraph>para1</paragraph>
<paragraph>para2</paragraph>
<comment classes="cover" xml:space="preserve"></comment>
<paragraph>para3</paragraph>
This looks good for LaTeX and HTML. I don't know if the extra comment node in the XML output would be a problem.