4

Pelican reStructuredText Link to Section in Another Page

 2 years ago
source link: http://siongui.github.io/2016/04/16/pelican-rst-link-to-section-in-another-page/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Introduction

Pelican static site generator - Link to section in another page via reStructuredText.

Assume you have a rst list-table as follows:

.. list-table:: Frozen Delights!
   :widths: 15 10 30
   :header-rows: 1

   * - Treat
     - Quantity
     - Description
   * - Albatross
     - 2.99
     - On a stick!
   * - Crunchy Frog
     - 1.49
     - If we took the bones out, it wouldn't be
       crunchy, now would it?
   * - Gannet Ripple
     - 1.99
     - On a stick!

You want to link to the table from another page. How to do it?

Solution

First add a reference label right before your table:

.. _my-reference-label:

.. list-table:: Frozen Delights!
   :widths: 15 10 30
   :header-rows: 1

   * - Treat
     - Quantity
     - Description
   * - Albatross
     - 2.99
     - On a stick!
   * - Crunchy Frog
     - 1.49
     - If we took the bones out, it wouldn't be
       crunchy, now would it?
   * - Gannet Ripple
     - 1.99
     - On a stick!

Please note that use lower-case name in your label. Because if not, it will become lower-case after converted to HTML.

Then in another page, you can link to the table as follows:

`link to table in another page <{filename}/path/to/your/file.rst#my-reference-label>`_

Please note that use lower-case name if your reference label.


Tested on: Ubuntu Linux 15.10, Python 2.7.10, Pelican 3.6.3.


References:

[1]rst link to section - Google search

[2]rst link to another page - Google search

[3]python sphinx - RestructuredText: Adding a cross-reference to a subheading or anchor in another page - Stack Overflow

[4]舊文部份移植:文章選讀 · twnanda/twnanda@5529ded · GitHub


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK