Skip to content

Web Edition

martin-henz edited this page Apr 22, 2020 · 5 revisions

Requirements

For development & deployment:

  • node.js

The generated web pages are static and can be hosted on any standard web servers.

Overview

The original text is stored as xml files in the xml folder.

The html pages are generated in three steps.

  1. Generate Table of Content, containing information on chapterIndex and chapterTitle of different chapters/sections/subsections.

  2. Process all xml files and set up Snippets and References

    setupSnippetsHtml function in processSnippetHtml.js file process all the <SNIPPET> tags found in the xml files and store their respective name, codeStr and requireName in an object snippetStore for later reference.

    setupReferencesHtml function in processReferenceHtml.js file found all <LABEL> tags in the xml files. Depend on their parent being <SECTION>, <FIGURE>, <EXERCISE> or <FOOTNOTE>, their respective referenceName, displayName, href and chapterIndex of the chapter they belong to are stored in an object referenceStore for later reference.

  3. Translate xml content to html and write into the generated html files inside html_js folder

    see parseXmlHtml.js file for further details on the translation process of each xml tags.

Set up

Run yarn install to install dependencies.

Deployment

yarn web

The generated html pages are saved in sicpjs_html folder.

Development

The entire program is located at nodejs. To test any changes made to the nodejs project, cd html_js && http-server --port=8080 to view the textbook on a local server, by visiting localhost:8080 with your browser.

For future developers, start with index.js and parseXmlHtml.js. Most of the remaining functions (helper functions) can be found being references from these two files.

Bugs

Clone this wiki locally