• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2# \
3exec tclsh "$0" "$@"
4
5# Copyright (C) 2009 The Trustees of Indiana University.
6# Use, modification and distribution is subject to the Boost Software
7# License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8# http://www.boost.org/LICENSE_1_0.txt)
9
10# Authors: Jeremiah Willcock, Andrew Lumsdaine
11
12foreach input [glob *.rst] {
13  set output [file join html "[file rootname $input].html"]
14  puts "Processing $input -> $output"
15  set processor [open "|rst2html.py --stylesheet=../../../../rst.css -gdt --link-stylesheet --traceback --trim-footnote-reference-space --footnote-references=superscript >$output" w]
16  set inputfd [open $input r]
17  set data [read $inputfd]
18  close $inputfd
19  foreach line [split $data \n] {
20    if {[regexp {^\.\. image:: (http:.*)$} $line _ url]} {
21      set tag $url
22      regsub -all {.*/} $tag {} tag
23      regsub -all {[^a-zA-Z0-9]} $tag _ tag
24      set imageoutput [file join html "$tag.png"]
25      puts "Getting image $url -> $imageoutput"
26      exec wget -q -O $imageoutput $url
27      puts $processor ".. image:: [file tail $imageoutput]"
28    } else {
29      puts $processor $line
30    }
31  }
32  close $processor
33}
34