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 ".. contents::" directive is ignored. #4108

Open
Varriount opened this issue Nov 29, 2017 · 5 comments
Open

reStructuredText ".. contents::" directive is ignored. #4108

Varriount opened this issue Nov 29, 2017 · 5 comments

Comments

@Varriount
Copy link

Pandoc Version: pandoc 2.0.3

Input:

Sample
======

.. contents:: Table of Contents

===========
Section One
===========
sample text

===========
Section Two
===========
sample text

Output (with pandoc -s sample.rst -o sample.html):

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="pandoc" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
  <title>Sample</title>
  <style type="text/css">
      code{white-space: pre-wrap;}
      span.smallcaps{font-variant: small-caps;}
      div.line-block{white-space: pre-line;}
      div.column{display: inline-block; vertical-align: top; width: 50%;}
  </style>
  <!--[if lt IE 9]>
    <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
  <![endif]-->
</head>
<body>
<header>
<h1 class="title">Sample</h1>
</header>
<div class="contents">
<p>Table of Contents</p>
</div>
<h1 id="section-one">Section One</h1>
<p>sample text</p>
<h1 id="section-two">Section Two</h1>
<p>sample text</p>
</body>
</html>

Expected output should be close to identical to the html output when --toc is used.

@jgm
Copy link
Owner

jgm commented Nov 29, 2017

Currently tables of contents are supported in the writers (often via templates).
So there's no way for the RST parser to ensure that the output will contain a TOC.

@jgm
Copy link
Owner

jgm commented Nov 29, 2017

See #1612

@arikrupnik
Copy link

Can the parser propagate the suggestion of where to insert the TOC? I think it's fine to ask the writer to generate it (perhaps only if the user specifies --toc) but when it does, can it insert it where the .. contents:: directive was?

@jgm
Copy link
Owner

jgm commented Aug 14, 2020

can it insert it where the .. contents:: directive was?

No, because it could be anywhere in the body, and pandoc just inserts the TOC in the template (where the whole body is just $body$).

@arikrupnik
Copy link

Gotcha. Thanks fort he fast response!

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

3 participants