Skip to content

Special syntax to wrap cell in a string macro #920

@MasonProtter

Description

@MasonProtter

I think that given that we don't have a way to hook into custom repl modes other than the ones hard coded into IJulia, it could be really nice to have a special syntax for wrapping the contents of a cell in a string macro. The idea would be that the string macros used in this way are analogous to custom repl modes, and the special syntax would allow us to use them in such a way that would not interfere with syntax highlighting and would require less typing.

For instance, if someone did using PyCall, they have access to the py_str macro so they could just have a codeblock that looks like

%% py
import numpy as np

def sinpi(x):
    return np.sin(np.pi * x)

sinpi(1)

would be translated into

py"""
import numpy as np

def sinpi(x):
    return np.sin(np.pi * x)

sinpi(1)
"""

Alternatively to the %% syntax, maybe we could just handle a comment on the first line specially, i.e. #mode mymode would use the mymode_str macro? I'm not sure what the best syntax to use would be.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions