Domanda

A title of "# Project Info" creates an element with the id "project-info". I can then link to that with "#project-info". When I have only one file, this works as expected. Here is what is happening: I have many files, project-a.md, project-b.md, etc.

All of these files have this same structure:

# Title

TOC: [Info](#project-info) | [Build](#project-build) | ...

## Project Info

## Project Build

...

I am creating an epub like this:

pandoc -S -o projects.epub title.txt project-a.md project-b.md project-c.md

The problem is that in the generated epub, the toc links for every project point to the sections for project a, instead of the respective project page. I opened the epub and the links are being rendered as this:

<a href="ch5.xhtml#project-info">Info</a>

This explains why they are linking to the first project but why is it adding ch5.xhtml to the link? Is there a to prevent this?

È stato utile?

Soluzione 2

Pandoc is concatenating the input files into one document first. This creates duplicate #names because they are now all in one file. This explains why the links are all jumping to the first project's bookmarks.

The solution is to make the #names unique across all input documents or use --TOC as John suggests.

Altri suggerimenti

This may be a bug in pandoc; you should report on pandoc's github issue tracker.

For your purposes, though, you're better off using the --toc command line flag, instead of manually creating a table of contents for each chapter. This will cause each chapter to begin with a table of contents, which you can style using CSS.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top