Skip to content

macros.md: Fix htmlized variant of first source code example #12732

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
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
2 changes: 1 addition & 1 deletion docs/docs/reference/metaprogramming/macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def assertImpl(expr: Expr[Boolean])(using Quotes) = '{
}

def showExpr(expr: Expr[Boolean])(using Quotes): Expr[String] =
'{ "<some source code>" } // Better implementation later in this document
'{ [actual implementation later in this document] }
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
'{ [actual implementation later in this document] }
'{ /* actual implementation later in this document */ }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That will also be eaten by whatever tool transforms the markdown to HTML, just as the other comment (probably all valid Scala comments?). I've no idea why a markdown-to-HTML converter would do that…

Copy link
Contributor

Choose a reason for hiding this comment

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

Handling of angle brackets in code blocks is mangled by scala style at #12734

Copy link
Contributor Author

@Flowdalic Flowdalic Jun 7, 2021

Choose a reason for hiding this comment

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

Probably, it is very common for Markdown code comments to require special handling of angle brackets. But I am talking about code comments, i.e. the \\ comment and /* comment */ which simply disappear in the htmlized output.

Copy link
Contributor

Choose a reason for hiding this comment

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

To confirm, if you remove scala from the triple-backticks, the angle brackets render correctly.

'{ "&lt;some source code&gt;" } // Better implementation later in this document

Copy link
Contributor

Choose a reason for hiding this comment

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

Otherwise it xmlifies as

</span><span id="11" class="">  '{ "
        <some source code>
         " } 
         <span class="hideable">// Better implementation later in this document</span>

        </some></span><pre></pre></code></pre>

Apologies if this was already discussed elsewhere, just mentioning what I noticed this morning.

Copy link
Contributor

Choose a reason for hiding this comment

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

The current version makes it readable. We can change it later if we want when the underlying issue is fixed.

```

If `e` is an expression, then `'{e}` represents the typed
Expand Down