From 86b753a7c61b9ef04013902b6104eb92439b38fd Mon Sep 17 00:00:00 2001 From: Philippus Date: Tue, 19 Apr 2022 08:47:50 +0200 Subject: [PATCH] Display code blocks inside details/summary correctly --- _overviews/scala3-macros/tutorial/inline.md | 12 ++++++++++-- _sass/layout/details-summary.scss | 3 +++ resources/css/style.scss | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 _sass/layout/details-summary.scss diff --git a/_overviews/scala3-macros/tutorial/inline.md b/_overviews/scala3-macros/tutorial/inline.md index c081b8d61c..30c445cef0 100644 --- a/_overviews/scala3-macros/tutorial/inline.md +++ b/_overviews/scala3-macros/tutorial/inline.md @@ -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" /}
- See rest of inlining steps + See rest of inlining steps + ```scala // then inlined as @@ -283,6 +286,8 @@ x2 * 1.0 ```
+{::options parse_block_html="false" /} + In contrast, let us imagine we do not know the value of `n`: ```scala @@ -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" /}
- See inlining steps + See inlining steps + ```scala // first inlines as @@ -318,6 +325,7 @@ else { ... ```
+{::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. diff --git a/_sass/layout/details-summary.scss b/_sass/layout/details-summary.scss new file mode 100644 index 0000000000..1f18d4cd64 --- /dev/null +++ b/_sass/layout/details-summary.scss @@ -0,0 +1,3 @@ +details > summary > p { + display: inline; +} diff --git a/resources/css/style.scss b/resources/css/style.scss index 57b121deba..fb5c150296 100755 --- a/resources/css/style.scss +++ b/resources/css/style.scss @@ -56,6 +56,7 @@ @import 'layout/blog'; @import 'layout/download'; @import 'layout/content-contributors'; // COMPONENTS +@import 'layout/details-summary'; //------------------------------------------------ //------------------------------------------------ @import 'components/buttons';