Skip to content

Commit

Permalink
Don't use .stripMargin for live-reload server
Browse files Browse the repository at this point in the history
Previously, the built-in live-reload server for mdoc processed markdown
output with `.stripMargin`. This meant that code examples using
`.stripMargin` formatted strings would not be rendered correctly in the
live-reload preview. This commit fixes that so that code examples with
`.stripMargin` are properly rendered.
  • Loading branch information
olafurpg committed Jun 12, 2021
1 parent 7e56511 commit 2c12357
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions mdoc/src/main/scala/mdoc/internal/livereload/SimpleHtml.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,32 @@ object SimpleHtml {
url: String
): String = {
val toc = tableOfContents.toHTML(fromLevel = 2, toLevel = 3, indent = " ")
s"""|<html>
|<head>
| <title>$title</title>
| <meta charset="UTF-8">
| <link rel="stylesheet" href="$url/github.css">
| <link rel="stylesheet" href="$url/custom.css">
| <script src="$url/highlight.js"></script>
| <script>
| hljs.configure({languages: []});
| hljs.initHighlightingOnLoad();
| </script>
| <script src="$url/livereload.js"></script>
|</head>
|<body>
| <div class="wrapper">
| <div class="main">
| $body
| </div>
| <div class="sidebar">
| $toc
| </div>
| </div>
|</body>
|</html>
|""".stripMargin
s"""
<html>
<head>
<title>$title</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="$url/github.css">
<link rel="stylesheet" href="$url/custom.css">
<script src="$url/highlight.js"></script>
<script>
hljs.configure({languages: []});
hljs.initHighlightingOnLoad();
</script>
<script src="$url/livereload.js"></script>
</head>
<body>
<div class="wrapper">
<div class="main">
$body
</div>
<div class="sidebar">
$toc
</div>
</div>
</body>
</html>
"""
}

}

0 comments on commit 2c12357

Please sign in to comment.