Code Monkey home page Code Monkey logo

pelican-global-rst-include's Introduction

Pelican Global RST Include

Global RST Include is a plugin for Pelican allowing for the convenient and straight-forward inclusion of global RST files into every RST article. This can make sense for central definitions of, for example, custom code roles, the default code role and abbreviations. Refer to my blog article for further motivation and background.

This repository is no longer maintained. Forks of this repository are probably improved and more up-to-date. https://github.com/ryancdotorg/pelican-global-rst-include appears to be compatible with newer versions of Pelican.

Usage

Clone this repository to a folder of your choice (best inside the pelican project folder). Then, add the relative path to this plugin to the list of plugins (PLUGINS in, e.g. pelicanconf.py) [1].

Now you can define which RST files should be included. For this, simply add the relative paths to the list RST_GLOBAL_INCLUDES. The contents of every file in there, will then be virtually [2] included at the beginning [3] of each of your RST articles.

Your pelicanconf.py and directory structure could now look like this:

# ...

PLUGIN_PATHS = [
    # other paths
    "plugins"
]

PLUGINS = [
    # other plugins
    "pelican-global-rst-include"
]

RST_GLOBAL_INCLUDES = [ "include/globals.rst" ]

# ...
pelican project
|-- include
|   |-- globals.rst
|-- content
|   |-- some_article.rst
|-- plugins
|   |-- pelican-global-rst-include
|....

Now, rerunning pelican will yield the modifications the global RST-files introduce to your articles.

[1]You can also utilize PLUGIN_PATH to set the path to your folder of plugins and, with this, shorten your relative plugin paths.
[2]The article file is not modified. Its contents are read, prepended by the contents to include and then processed.
[3]Ordering is preserved. The content of the first include file in the list will be at the very beginning of the aggregated contents to be processed.

Settings

RST_GLOBAL_INCLUDES
list of RST-files (relative to pelican project root) to be injected into all RST-articles

Possible Issues & Future Work

Unfortunately, Docutils is very hardcoded when it comes to reading and parsing source files. It may be extensible when it comes to actually modifying the Docutils code, but as a user of the system things get ugly.

Out of this several (possible) issues arise:

  • Updates to Docutils could break this plugin
  • Subtle bugs could be contained.
  • docutils.io.FileInput shows several signs of handling encoding different when using a python version above 3.0. It could be that the global include files should be handled the same way for the subsequent concatenation to be consistent.

License

Published under the MIT license.

pelican-global-rst-include's People

Contributors

mhoff avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.