Skip to content

Commit d604e91

Browse files
committed
add hack to inject link in html soup of lecture overview
1 parent 74036f6 commit d604e91

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

plan/Main.scala

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@ object Main extends App {
2121

2222
object modulePlan extends Plan with Table {
2323
override val heading = Seq("W", "Modul", "Innehåll")
24+
def toHtmlPatched: String = { // a hack to insert links to lectures
25+
var htmlSoup = toHtml
26+
column("Modul").zipWithIndex.take(1).foreach{ case (m, i) =>
27+
println(s"Patching html link in module: $m")
28+
def href(m: String): String = {
29+
val w = column("W").apply(i).toLowerCase
30+
s"""<a href="https://fileadmin.cs.lth.se/pgk/lect-$w.pdf">$m</a>"""
31+
}
32+
htmlSoup = htmlSoup.replaceAllLiterally(s"$m</td>",s"${href(m)}</td>")
33+
}
34+
htmlSoup
35+
}
2436
}
2537

2638
object overview extends Plan with Table {
@@ -31,15 +43,15 @@ object Main extends App {
3143
weekPlan. toMarkdown.save(currentDir + "week-plan-generated.md")
3244
weekPlan. toHtml .save(currentDir + "week-plan-generated.html")
3345
weekPlan. toLatex .prepend(texUtf).save(currentDir + "week-plan-generated.tex")
34-
modulePlan.toMarkdown.save(currentDir + "module-plan-generated.md")
35-
modulePlan.toHtml .save(currentDir + "module-plan-generated.html")
46+
modulePlan.toMarkdown. save(currentDir + "module-plan-generated.md")
47+
modulePlan.toHtmlPatched. save(currentDir + "module-plan-generated.html")
3648
modulePlan.latexTableBody.save(currentDir + "module-plan-generated.tex")
3749
overview .toLatex .prepend(texUtf).save(currentDir + "overview-generated.tex")
3850

39-
val weeks = (0 to 6) ++ (8 to 14) //exlude exam weeks
51+
lazy val weeks = (0 to 6) ++ (8 to 14) //exlude exam weeks
4052

4153
// *** Generate chapter heads with topics of each module
42-
val minConceptsForTwoCol = 28
54+
lazy val minConceptsForTwoCol = 28
4355

4456
def conceptBegin(n: Int) = "Begrepp som ingår i denna veckas studier:\n" +
4557
(if (n > minConceptsForTwoCol) """\begin{multicols}{2}""" else "") +

plan/module-plan-generated.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<tbody>
99
<tr>
1010
<td align="left">W01</td>
11-
<td align="left">Introduktion</td>
11+
<td align="left"><a href="https://fileadmin.cs.lth.se/pgk/lect-w01.pdf">Introduktion</a></td>
1212
<td align="left">sekvens, alternativ, repetition, abstraktion, editera, kompilera, exekvera, datorns delar, virtuell maskin, litteral, värde, uttryck, identifierare, variabel, typ, tilldelning, namn, val, var, def, definera och anropa funktion, funktionshuvud, funktionskropp, procedur, inbyggda grundtyper, Int, Long, Short, Double, Float, Byte, Char, String, println, typen Unit, enhetsvärdet (), stränginterpolatorn s, if, else, true, false, MinValue, MaxValue, aritmetik, slumptal, math.random, logiska uttryck, de Morgans lagar, while-sats, for-sats</td></tr>
1313
<tr>
1414
<td align="left">W02</td>

0 commit comments

Comments
 (0)