-
Notifications
You must be signed in to change notification settings - Fork 124
JSON
For development & deployment:
- node.js
The generated JSON files can be hosted on any standard web server.
The JSON version of SICP JS converts the WEB version of SICP JS into JSON files so that they can be easily processed by other programs.
yarn json
JSON files will be in the /json
folder.
yarn json
yarn prepare
yarn try
Files can be accessed by visiting localhost:8080/json/FILENAME.json
, where FILENAME
is the filename as shown in the /json
folder.
The JSON files can also be accessed on source-academy.github.io/sicp/json/FILENAME.json
.
To deploy on your own GitHub pages domain, run the deploy-pages
GitHub action and replace source-academy.github.io
with your own domain name.
The JSON files have a tree like structure, with objects on the same level (same array) being sibling nodes and objects nested within other objects are child nodes.
The root of the JSON file is an array containing one or more objects. Each object represents a node and has the following structure:
{
tag: Name of Node
body: Contents of node
⋮ (other attributes if needed)
child: [{...obj}]
}
The following sections document the structure of the different objects. Each object has a tag attribute that is omitted for clarity. A ?
beside an attribute is used to indicate an optional attribute.
An object containing pure text.
- body: text, string
A paragraph of text.
- id: id, string
- child: obj[]
Title of a section.
- id: id, string
- body: title, string
- OL: Ordered List
- UL: Unordered List
- LI: List Item
OL and UL objects contain an array of LI objects under the attribute child
.
- body: title, string
- child: LI[]
- child: obj[]
Similar to tables in html, A table contains some TR (table row) and each TR contains some TD (table data).
- child: TR[]
- child: TD[]
- child: obj[]
Children to be formatted using LaTeX. For METAPHRASE tags, a < >
is to be added surrounding the text. LATEX is displayed as a block while LATEXINLINE, META and METAPHRASE are displayed inline.
- child: text to format, obj[]
Links to other content. LINK links to an external page, REF links to a section on the same page and FOOTNOTEREF links to a footnote and is to be displayed in superscript.
- id: id, string
- href: link, string
- body: text to display, string
A Blockquote.
- author?: author, string
- title?: title, string
- date?: date, string
- child: content of blockquote, obj[]
An exercise with or without a solution
- id: id, string
- title: title, string
- child: exercise question, obj[]
- solution?: exercise solution, obj[]
Footnote to display.
- count: one-based index of footnote, integer
- id: id, string
- href: link to FOOTNOTE-REF, string
- child: content of footnote, obj[]
A reference in the reference page.
- child: obj[]
This tags should be replaced with a line break.
These tags should apply styling to their child components.
- B - Bold
- EM - Emphasis
- JAVASCRIPTINLINE - Inline javascript
- TT - Generic Code
- child: obj[]
A figure containing either image src, table or snippet. It may also have a caption.
- id: id, string
- scale?: scale of image, string (e.g. 50%)
- src?: src of image, string
- snippet?: snippet, obj
- table?: table, obj
- captionName?: name of caption, string
- captionBody?: content of caption, obj[]
A code snippet. If eval property is false, the code block should not be evaluated. if latex property is true, the code block should be parsed using latex. eval and latex cannot be both true at the same time.
- id: id, string
- body: code in plain text, string
- eval: eval flag, boolean
- latex: latex flag, boolean
- output?: output of program, string
- program: compressed string of full program, string
- prependLength: length of prepend (may be 0), number