Section4.9Testing HTML Output Locally¶
Certain complicated parts of HTML output will not always function when you look at PreTeXt output by just opening files in your web browser. These include knowls, Sage cells, and YouTube videos. This is a consequence of security policies and so will vary from browser to browser. A solution is to run a web server on your own machine, which is much easier than it sounds. The one prerequisite is that you have Python installed, as is normally the case on any Linux or Mac computer. On Windows, you may need to install Python yourself, but you may eventually need it for the
mbx script anyway (Chapter 8). The following has been tested on Ubuntu Linux 16.10 and MacOS 10.12 (2017-08-06).
Python 2 and Python 3 are different in some regards, and that is the case here. Your system may have commands
python3, and/or plain
python. Experiment with variants of the following two commands. First, at a command-line, set your working directory to be the location of a directory containing the HTML files you want to test.
python3 -m http.server python2 -m SimpleHTTPServer
--help if you want to see the (limited) options for configuration. Then go to the address bar of your browser and use
to actually view the files from a web server. Running the Python command should tell you which address to use (the
0.0.0.0) and your project might not have an
index.html file, so adjust accordingly.
You may also be able to configure your
hosts file so that this webserver looks like it lives somewhere else. Clues at