Skip to content

use dotty website code highlighting #2798

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions _includes/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
<!-- Blog search -->
<script src="{{ site.baseurl }}/resources/js/vendor/jekyll.search.min.js" type="text/javascript"></script>

<!-- Custom Syntax Highlight -->
<script src="{{ site.baseurl }}/resources/js/hljs-scala3.js" type="text/javascript"></script>

<!-- Custom JavaScript -->
<script src="{{ site.baseurl }}/resources/js/functions.js" type="text/javascript"></script>

Expand Down
19 changes: 18 additions & 1 deletion _overviews/scala3-book/first-look-at-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ val list: List[Any] = List(
"a string",
732, // an integer
'c', // a character
'\'', // a character with a backslash escape
true, // a boolean value
() => "an anonymous function returning a string"
)
Expand All @@ -76,6 +77,7 @@ Here’s the output of the program:
a string
732
c
'
true
<function>
```
Expand Down Expand Up @@ -119,7 +121,22 @@ In your code you can also append the characters `L`, `D`, and `F` (and their low
```scala
val x = 1_000L // val x: Long = 1000
val y = 2.2D // val y: Double = 2.2
val z = 3.3F // val z: Float = 3.3
val z = -3.3F // val z: Float = -3.3
```

You may also use hexadecimal notation to format integer numbers (normally `Int`, but which also support the
`L` suffix to specify that they are `Long`):

```scala
val a = 0xACE // val a: Int = 2766
val b = 0xfd_3aL // val b: Long = 64826
```

Scala supports many different ways to format the same floating point number, e.g.
```scala
val q = .25 // val q: Double = 0.25
val r = 2.5e-1 // val r: Double = 0.25
val s = .0025e2F // val s: Float = 0.25
```
{% endtab %}
{% endtabs %}
Expand Down
3 changes: 2 additions & 1 deletion resources/js/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ $(document).ready(function() {
hljs.configure({
languages: ["scala", "bash"]
})
hljs.registerLanguage("scala", highlightDotty);
hljs.highlightAll();
});

Expand Down Expand Up @@ -431,7 +432,7 @@ $(document).ready(function() {
function setupTabs(tabs, namespace, defaultValue) {
const PreferenceStorage = Storage('org.scala-lang.docs.preferences');
const preferredValue = PreferenceStorage.getPreference(namespace, defaultValue);

activateTab(tabs, preferredValue)

// setup listeners to record new preferred Scala version.
Expand Down
Loading