Skip to content

Commit 11d3ce4

Browse files
authored
use dotty website code highlighting (scala#2798)
* use dotty website code highlighting * handle better words with 'def'
1 parent 0eeb790 commit 11d3ce4

File tree

4 files changed

+499
-2
lines changed

4 files changed

+499
-2
lines changed

_includes/footer.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
<!-- Blog search -->
5454
<script src="{{ site.baseurl }}/resources/js/vendor/jekyll.search.min.js" type="text/javascript"></script>
5555

56+
<!-- Custom Syntax Highlight -->
57+
<script src="{{ site.baseurl }}/resources/js/hljs-scala3.js" type="text/javascript"></script>
58+
5659
<!-- Custom JavaScript -->
5760
<script src="{{ site.baseurl }}/resources/js/functions.js" type="text/javascript"></script>
5861

_overviews/scala3-book/first-look-at-types.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ val list: List[Any] = List(
5858
"a string",
5959
732, // an integer
6060
'c', // a character
61+
'\'', // a character with a backslash escape
6162
true, // a boolean value
6263
() => "an anonymous function returning a string"
6364
)
@@ -76,6 +77,7 @@ Here’s the output of the program:
7677
a string
7778
732
7879
c
80+
'
7981
true
8082
<function>
8183
```
@@ -119,7 +121,22 @@ In your code you can also append the characters `L`, `D`, and `F` (and their low
119121
```scala
120122
val x = 1_000L // val x: Long = 1000
121123
val y = 2.2D // val y: Double = 2.2
122-
val z = 3.3F // val z: Float = 3.3
124+
val z = -3.3F // val z: Float = -3.3
125+
```
126+
127+
You may also use hexadecimal notation to format integer numbers (normally `Int`, but which also support the
128+
`L` suffix to specify that they are `Long`):
129+
130+
```scala
131+
val a = 0xACE // val a: Int = 2766
132+
val b = 0xfd_3aL // val b: Long = 64826
133+
```
134+
135+
Scala supports many different ways to format the same floating point number, e.g.
136+
```scala
137+
val q = .25 // val q: Double = 0.25
138+
val r = 2.5e-1 // val r: Double = 0.25
139+
val s = .0025e2F // val s: Float = 0.25
123140
```
124141
{% endtab %}
125142
{% endtabs %}

resources/js/functions.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ $(document).ready(function() {
6767
hljs.configure({
6868
languages: ["scala", "bash"]
6969
})
70+
hljs.registerLanguage("scala", highlightDotty);
7071
hljs.highlightAll();
7172
});
7273

@@ -431,7 +432,7 @@ $(document).ready(function() {
431432
function setupTabs(tabs, namespace, defaultValue) {
432433
const PreferenceStorage = Storage('org.scala-lang.docs.preferences');
433434
const preferredValue = PreferenceStorage.getPreference(namespace, defaultValue);
434-
435+
435436
activateTab(tabs, preferredValue)
436437

437438
// setup listeners to record new preferred Scala version.

0 commit comments

Comments
 (0)