summaryrefslogtreecommitdiff
path: root/book/src/main/scala/book/Utils.scala
diff options
context:
space:
mode:
Diffstat (limited to 'book/src/main/scala/book/Utils.scala')
-rw-r--r--book/src/main/scala/book/Utils.scala17
1 files changed, 15 insertions, 2 deletions
diff --git a/book/src/main/scala/book/Utils.scala b/book/src/main/scala/book/Utils.scala
index 6770e31..171d0ad 100644
--- a/book/src/main/scala/book/Utils.scala
+++ b/book/src/main/scala/book/Utils.scala
@@ -171,14 +171,27 @@ object hl{
val whitespace = indent(lines(startLine))
val endLine = lines.indexWhere(
line => line.contains(end) || (indent(line) < whitespace && line.trim != ""),
- startLine
+ startLine + 1
)
val sliced =
if (endLine == -1) lines.drop(startLine)
else lines.slice(startLine, endLine)
+
val blob = sliced.map(_.drop(whitespace)).mkString("\n")
- pre(code(cls:=lang + " highlight-me", blob))
+ pre(
+ code(cls:=lang + " highlight-me", blob),
+ a(
+ cls:="header-link",
+ i(cls:="fa fa-link "),
+ position.absolute,
+ right:="0.5em",
+ bottom:="0.5em",
+ display.block,
+ fontSize:="24px",
+ href:="#"
+ )
+ )
}
} \ No newline at end of file