Oliver Zheng
Oliver Zheng

Reputation: 8199

What is a simple webpage compiler for restructured text?

Instead of a blog/cms, I'd like to have a static html-based site with a few (rarely updated) pages. I figure the simplest way to update them is to keep the sources in a format like ReST, and compile it each time it updates. What is a recommended compiler for this usage? I'd like to have my own theme/design and I don't need anything beyond the proper ReST syntax (Sphinx is too much, for example).

Upvotes: 3

Views: 4118

Answers (5)

Dacav
Dacav

Reputation: 14078

You may want to use a static site generator. There's a billion of them…

https://www.staticgen.com/

Upvotes: 0

altercation
altercation

Reputation: 2137

I use nanoc3 along with docutils (via a sphinx install) to enable nice restructuredtext support in a static site generator. I've looked at (and would like to use) a pure python solution (hyde) but nanoc allows for cleaner ReST source files.

I've also considered using sphinx to produce a static site, but it's not as easy to do this without rolling a lot of code to support it.

I'm happy to detail how to do this precisely if there is still interest in this topic. It's basically using docutils to output html from the source rest. I have a simple nanoc processor that does this:

module Nanoc3::Filters

  class ReST < Nanoc3::Filter

    identifier :rest

    def run(content, params={})
      open('|rst2html.py --template=rest.template', 'r+') do |io|
        io.write(content)
        io.close_write
        io.read
      end
    end

  end

end

The rest.template file is basically a dummy template with the following single line:

%(body)s

Upvotes: 0

Christian
Christian

Reputation: 9486

If you dont necessarily need restructured text, but markdown or textile is just as fine, then check out jekyll.

I use it myself. Thumbs up.

Upvotes: 1

Geoff Reedy
Geoff Reedy

Reputation: 36011

rest2web might be more the sort of thing you're looking for.

Upvotes: 2

Geoff Reedy
Geoff Reedy

Reputation: 36011

A Makefile would be a good solution to do this. Here's a quick template makefile

# Flags to pass to rst2html
# e.g. RSTFLAGS = --stylesheet-path=mystyle.css 
RSTFLAGS = 

%.html: %.rst
        rst2html $(RSTFLAGS) $< $@

.PHONY: all
.DEFAULT: all

all: index.html foo.html bar.html # any other html files to be generated from an rst file

Then just run make in the directory with your files to generate the html from the rst

Upvotes: 6

Related Questions