-
Notifications
You must be signed in to change notification settings - Fork 101
Julia console support #98
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
Comments
General support for non-Python consoles will involve some reworking of the PythonTeX internals. Since PythonTeX is written in Python, and there's the
If someone can solve the problem of taking Julia code, processing it as console input, and then creating console-style output, then I think that adding PythonTeX support would be relatively quick and straightforward. |
It looks like we have a solution to your second option here. |
That looks like a good option. Getting this to work would involve creating a new set of templates in I have several deadlines that will keep me busy for the next couple weeks, but I can probably make an attempt myself at some point after that. The work I'm finishing up over the next couple of weeks will actually lay the groundwork for redoing language support in PythonTeX. The goal is to make things much more extensible, and split all of the templates out of |
Whats the required output format for Pythontex? I can add it to Weave.jl if needed. |
I can be patient for your refactor, @gpoore. Thanks for all your work on pythontex. It is a really great tool. |
I'm back to looking at this...the config format for redoing PythonTeX language support and eventually allowing some features to be used with Markdown is largely complete (https://bespon.org/). @mpastell The script format with Unless I'm overlooking something, there does appear to be one limitation in I'm starting into the PythonTeX refactor that should get this working, and will try to post some updates if it looks like that will be slow. |
@gpoore Awesome. We're looking forward to this and will start using it in our book as soon as it is available. |
How is the refactor going? Is help needed? |
I've added a basic This is built on top of the existing Sample document: \documentclass{article}
\usepackage[usefamily=juliacon]{pythontex}
\begin{document}
text
\begin{juliaconsole}
x = 1:10
y = Dict(:language => "julia")
\end{juliaconsole}
\end{document} |
This sounds great! I will add support for errors in |
Yep, this does what we need. Syntax highlighting would be great! Thanks! |
Syntax highlighting now works, and there are no longer incorrect error/warning messages. You can set the highlighting style with something like this in the preamble: \setpythontexpygopt[juliacon]{style=default} The one current drawback is that changing highlighting style won't necessarily take effect unless code is modified. |
Just FYI for new users in the future, if you don't have Weave installed, you might get an error message like this:
To fix, just go into Julia and run |
When I run your example document:
It seems to evaluate every line and return its output, with a blank line between each output. However, this seems to be different from how the Python console works (sec. 4.2.3 of pythontex manual). Is this intentional? I think it prevents us from using multiline commands. Am I missing something? |
@mykelk I'll add a note to the docs about installing In terms of the output, I believe the empty lines after all output are mimicking the Julia console exactly. When I run
Meanwhile, when I run >>> x = range(1,10)
>>> x
range(1, 10)
>>> y = {"language": "python"} This looks like there are just differences in how Julia and Python format their console output. There may be a way to modify that, but that would involve a Multiline Julia seems to work fine. For example, reformatting the sample document: \documentclass{article}
\usepackage[usefamily=juliacon]{pythontex}
\begin{document}
text
\begin{juliaconsole}
x = 1:10
y = Dict(
:language => "julia"
)
\end{juliaconsole}
\end{document} |
It also seems that comments mess things up: \begin{juliaconsole}
2*2
2^5
# This is a comment
2^5
\end{juliaconsole} This yields:
|
@mykelk This is what I have, with Pygments 2.2.0. The continuation lines seem to work fine. Maybe you have an older version of Pygments? @mlhetland That looks like a limitation in |
Ah, OK. Thanks. |
@mlhetland Yes, the second (closing) parenthesis is gray. I'm not sure if that's due to a limitation in Pygments when working with multiline elements, or (probably more likely) an indication that the Pygments Julia console lexer needs improvement. |
@mykelk All empty console lines can be removed by adding this to the preamble of the \makeatletter
\AtBeginEnvironment{juliaconsole}{%
\def\FV@@PreProcessLine{%
\expandafter\ifstrempty\expandafter{\FV@Line}{}{%
\FV@StepLineNo
\FV@Gobble
\expandafter\FV@ProcessLine\expandafter{\FV@Line}}}%
}
\makeatother This discards all empty lines in Julia console environments (doesn't check for |
Oh, wow, that is exactly what I want!!! Thanks so much. |
Is this feature supposed to exist in pythontex 0.16? It is not working for me as follows. Created this file, \documentclass{article}
\usepackage[usefamily=juliacon]{pythontex}
\begin{document}
\begin{juliaconsole}
x = 1:10
y = Dict(:language => "julia")
\end{juliaconsole}
\end{document} Ran pythontex on it, getting this output:
If I do |
Which version of Julia are you using? I don't think Julia 1.0 is supported yet. |
|
What does the |
@nathancarter Do you have |
That solved it. My apologies if that's documented somewhere and I missed it. I came to this feature through this Stack Exchange question and answer and thus didn't read too many docs. Thanks for the help!! |
What is involved in adding Julia console support? Is this part of the roadmap, or is it really tricky in the near term?
The text was updated successfully, but these errors were encountered: