77
88import os
99import shutil
10+ from urllib .parse import quote
1011from subprocess import Popen , PIPE
1112
1213def read_file (filepath ):
@@ -54,7 +55,7 @@ def build_sections(sources):
5455 next_chap_name = "Table of contents"
5556 if (i + 1 ) < len (chapters ):
5657 next_section , next_chap_name , _ = chapters [i + 1 ]
57- next_chap_href = "../{}/{}.html" .format (next_section , next_chap_name )
58+ next_chap_href = "../{}/{}.html" .format (quote ( next_section , safe = '' ), quote ( next_chap_name , safe = '' ) )
5859 if not os .path .exists (section ):
5960 os .makedirs (section )
6061 chapter_path = "../../" + chapter_source
@@ -75,10 +76,11 @@ def build_sections(sources):
7576 "lhs-source-href" : lhs_source_href ,
7677 "lhs-source-name" : lhs_source_name ,
7778 })
78- out_path = "{}/{}.html" .format (section , chapter_name )
79+ out_path = "{}/{}.html" .format (section , chapter_name )
80+ out_path_u = "{}/{}.html" .format (quote (section , safe = '' ), quote (chapter_name , safe = '' ))
7981 write_string_to_file (chapter , out_path )
8082 copy_images (os .path .dirname (chapter_path ), section )
81- prev_chap_href = "../" + out_path
83+ prev_chap_href = "../" + out_path_u
8284 prev_chap_name = chapter_name
8385
8486def build_index (sources ):
@@ -88,7 +90,7 @@ def build_index(sources):
8890 toc += "<div>" + section_name + "</div>\n "
8991 toc += "<ul>\n "
9092 for (chapter_name , _ ) in chapter_sources :
91- chapter_path = "{}/{}.html" .format (section_name , chapter_name )
93+ chapter_path = "{}/{}.html" .format (quote ( section_name , safe = '' ), quote ( chapter_name , safe = '' ) )
9294 toc += "<li><a href=\" {}\" >{}</a></li>\n " .format (chapter_path , chapter_name )
9395 toc += "</ul>\n </li>\n "
9496 index_template = open_template ("index" )
@@ -97,17 +99,20 @@ def build_index(sources):
9799
98100sources = [
99101 ("Introduction" , [
100- ("Introduction'" , "Physics/src/Introduction/Introduction.lhs" ),
102+ ("About this book" , "Physics/src/Introduction/About.lhs" ),
103+ ("So what's a DSL?" , "Physics/src/Introduction/WhatIsADsl.lhs" ),
104+ ("Getting started" , "Physics/src/Introduction/GettingStarted.lhs" ),
101105 ]),
102106 ("Calculus" , [
103107 ("Introduction" , "Physics/src/Calculus/Intro.lhs" ),
104108 ("Function expressions" , "Physics/src/Calculus/FunExpr.lhs" ),
105109 ("Differential calculus" , "Physics/src/Calculus/DifferentialCalc.lhs" ),
106110 ("Integral calculus" , "Physics/src/Calculus/IntegralCalc.lhs" ),
107- ("Visualization" , "Physics/src/Calculus/VisVerApp.lhs" ),
111+ ("Plotting graphs" , "Physics/src/Calculus/VisVerApp.lhs" ),
112+ ("Syntax trees" , "Physics/src/Calculus/SyntaxTree.lhs" ),
108113 ]),
109- ("Vectors " , [
110- ("Vector " , "Physics/src/Vector/Vector.lhs" )
114+ ("Linear algebra " , [
115+ ("Vectors " , "Physics/src/Vector/Vector.lhs" )
111116 ]),
112117 ("Dimensions" , [
113118 ("Introduction" , "Physics/src/Dimensions/Intro.lhs" ),
@@ -116,16 +121,17 @@ def build_index(sources):
116121 "Physics/src/Dimensions/ValueLevel/Test.lhs" ),
117122 ("Type-level dimensions" , "Physics/src/Dimensions/TypeLevel.lhs" ),
118123 ("Quantities" , "Physics/src/Dimensions/Quantity.lhs" ),
119- ("Testing of Quantity " ,
124+ ("Testing of Quantities " ,
120125 "Physics/src/Dimensions/Quantity/Test.lhs" ),
121126 ("Usage" , "Physics/src/Dimensions/Usage.lhs" ),
122127 ]),
128+ ("Newtonian Mechanics" , [
129+ ("Single particle mechanics" , "Physics/src/NewtonianMechanics/SingleParticle.lhs" )
130+ ]),
123131 ("Examples" , [
124- ("Gungbräda" , "Physics/src/Examples/Gungbraeda.lhs" ),
125- ("krafter på lådor" , "Physics/src/Examples/krafter_pa_lador.lhs" ),
126-
132+ ("Teeter" , "Physics/src/Examples/Teeter.lhs" ),
133+ ("Box on an incline" , "Physics/src/Examples/Box_incline.lhs" ),
127134 ])
128-
129135]
130136
131137if not os .path .exists ("build" ):
0 commit comments