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

Conversation

Flowdalic
Copy link
Contributor

Confusingly, the last part of the first source code example would
appear as

def showExpr(expr: Expr[Boolean])(using Quotes): Expr[String] =
'{ "

     " }

in the htmlized version of the markdown documentation source. Which
reads as follows:

def showExpr(expr: Expr[Boolean])(using Quotes): Expr[String] =
'{ "" } // Better implementation later in this document

This seems to be cause by the usage of angle brackets. Also note that
the code comment does not appear in the htmlized output.

Confusingly, the last part of the first source code example would
appear as

def showExpr(expr: Expr[Boolean])(using Quotes): Expr[String] =
  '{ "

         " }

in the htmlized version of the markdown documentation source. Which
reads as follows:

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

This seems to be cause by the usage of angle brackets. Also note that
the code comment does not appear in the htmlized output.
@@ -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.

@nicolasstucki nicolasstucki merged commit ea2a975 into scala:master Jun 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants