Skip to content

Display code blocks inside details/summary correctly #2380

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 1 commit into from
Apr 20, 2022
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
12 changes: 10 additions & 2 deletions _overviews/scala3-macros/tutorial/inline.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,11 @@ Calling `power` with statically known constants results in the following code:
val x = 2
power(x * x, 1)
```

{::options parse_block_html="true" /}
<details>
<summary> See rest of inlining steps</summary>
<summary>See rest of inlining steps
</summary>

```scala
// then inlined as
Expand Down Expand Up @@ -283,6 +286,8 @@ x2 * 1.0
```
</details>

{::options parse_block_html="false" /}

In contrast, let us imagine we do not know the value of `n`:

```scala
Expand All @@ -291,8 +296,10 @@ power(2, unknownNumber)
Driven by the inline annotation on the parameter, the compiler will try to unroll the recursion.
But without any success, since the parameter is not statically known.

{::options parse_block_html="true" /}
<details>
<summary>See inlining steps</summary>
<summary>See inlining steps
</summary>

```scala
// first inlines as
Expand All @@ -318,6 +325,7 @@ else {
...
```
</details>
{::options parse_block_html="false" /}

To guarantee that the branching can indeed be performed at compile-time, we can use the `inline if` variant of `if`.
Annotating a conditional with `inline` will guarantee that the conditional can be reduced at compile-time and emits an error if the condition is not a statically known constant.
Expand Down
3 changes: 3 additions & 0 deletions _sass/layout/details-summary.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
details > summary > p {
display: inline;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to make sure the little arrow is on the same line as "See inlining steps".

}
1 change: 1 addition & 0 deletions resources/css/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
@import 'layout/blog';
@import 'layout/download';
@import 'layout/content-contributors'; // COMPONENTS
@import 'layout/details-summary';
//------------------------------------------------
//------------------------------------------------
@import 'components/buttons';
Expand Down