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

reStructuredText metadata is wrapped in <p> #7766

Closed
not-my-profile opened this issue Dec 20, 2021 · 3 comments
Closed

reStructuredText metadata is wrapped in <p> #7766

not-my-profile opened this issue Dec 20, 2021 · 3 comments

Comments

@not-my-profile
Copy link
Contributor

not-my-profile commented Dec 20, 2021

Explain the problem.

$ echo '$foo$' > /tmp/foo.html
$ printf '---\nfoo: bar\n---' | pandoc -f markdown --template=/tmp/foo.html
bar
$ printf '=\nA\n=\n:foo: bar' | pandoc -f rst --template=/tmp/foo.html
<p>bar</p>

With RST the metadata value is wrapped in a <p> tag meaning variables cannot be interpolated into attribute values.

(It's worth noting that docutils also does some paragraph normalization).

On a related note it would be nice if lists were preserved as well:

$ printf '$for(foo)$xx $foo$ xx\n$endfor$' > /tmp/foo.html
$ printf '---\nfoo: [bar, baz]\n---' | pandoc -f markdown --template=/tmp/foo.html
xx bar xx
xx baz xx
$ printf '=\nA\n=\n:foo: - bar\n - buz' | pandoc -f rst --template=/tmp/foo.html
xx <ul>
<li>bar</li>
<li>buz</li>
</ul> xx

Pandoc version?
pandoc 2.16.2 on Linux

@jgm
Copy link
Owner

jgm commented Dec 21, 2021

rst2xml gives:

<docinfo><field classes="foo"><field_name>foo</field_name><field_body><paragraph>bar</paragraph></field_body></field></docinfo>

for your input. Note the <paragraph>. So I think pandoc's behavior is correct here. (Note that pandoc removes the paragraph from title, author, date.)

@not-my-profile
Copy link
Contributor Author

not-my-profile commented Dec 21, 2021

Interesting. printf '=\nA\n=\n:foo: bar' | rst2html gives

<table class="docinfo" frame="void" rules="none">
<col class="docinfo-name" />
<col class="docinfo-content" />
<tbody valign="top">
<tr class="foo field"><th class="docinfo-name">foo:</th><td class="field-body">bar</td>
</tr>
</tbody>
</table>

Note that there is no <p>. This issue is specifically about being able to interpolate non-standard metadata without the <p> wrapping.

@jgm
Copy link
Owner

jgm commented Dec 21, 2021

Interesting.
We could easily convert all single Para metadata fields into single Plain ones. But I don't know if that's the right behavior either. Note:

% printf '=\nA\n=\n:abstract: bar' | rst2html
...snip...
<div class="abstract topic">
<p class="topic-title">Abstract</p>
<p>bar</p>
</div>
...

@jgm jgm closed this as completed in 812b264 Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants