Skip to content
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

Syntax highlighting for indented code blocks #978

Closed
christopher-dG opened this issue Mar 5, 2019 · 3 comments
Closed

Syntax highlighting for indented code blocks #978

christopher-dG opened this issue Mar 5, 2019 · 3 comments

Comments

@christopher-dG
Copy link
Contributor

The usual convention for docstrings is to do something like this:

"""
    myfunction(myarg::MyType) -> MyReturnType

My function.
"""

But when you do this instead of a triple-backticked code block, you lose out on syntax highlighting. Would it be possible to convert indented code blocks into backticked Julia ones?

@mortenpi mortenpi added Status: Speculative It's unknown if this is something that we wan't to do Type: Enhancement labels Mar 5, 2019
@mortenpi
Copy link
Member

mortenpi commented Mar 5, 2019

The parser in the Markdown stdlib does not distinguish between triple-backticked and indented code blocks (i.e. the resulting AST is the same). So the only way to achieve this would be to always apply Julia highlighting to all code blocks that do not specify the language. However, I am a bit hesitant, as that goes against how Markdown code blocks are meant to be interpreted in my opinion.

I guess, another way would be to special-case this particular use case -- the first code block in a docstring gets highlighted as Julia (unless another language is explicitly specified).

Edit: OTOH, maybe we should default to Julia? Related recent discussion: JuliaLang/julia#31009 (comment)

@christopher-dG
Copy link
Contributor Author

Thanks for this info. I'm also a little hesitant of defaulting to Julia, maybe an alternative could be an opt-in makedocs option which sets the default?
I do also like the special case idea.

@mortenpi
Copy link
Member

mortenpi commented Mar 7, 2019

We could have an opt-out special casing maybe?

@mortenpi mortenpi removed the Status: Speculative It's unknown if this is something that we wan't to do label Mar 10, 2019
@mortenpi mortenpi added this to the 0.22.0 milestone Mar 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants