Comments (11)
Have you ever tried to use IPyStata in a non-Jupyter Notebook environment? Specifically Hydrogen, Jupyter console, or Jupyter QtConsole? Jupyter Notebook is the only one of the four that use CodeMirror for syntax highlighting (Jupyter console and Qtconsole use Pygments, and Hydrogen uses my Atom Stata syntax highlighting package). I'm not sure it's ideal for me to be serving up Javascript that those frontends won't be able to handle.
The best option would just be to add Stata syntax highlighting to the CodeMirror repository itself. Though then there would be a lag until the next release and when Jupyter Notebook uses that next release.
I can look into this a bit more in the future, but at the moment it isn't a high priority compared to making sure the package is stable.
from stata_kernel.
I've used Stata for a while just realized that "in" doesn't get highlighted in Stata's syntax?
from stata_kernel.
Highlighted where? Are you using Jupyter Notebook, Jupyter Console, or Atom? Each uses different syntax highlighters.
from stata_kernel.
The syntax doesn't get highlighted in Jupyter Lab unless I export an HTML file. nteract doesn't highlight the syntax either. It seems only Atom does so far based on your stata-language package.
from stata_kernel.
Jupyter notebook and I assume Jupyter lab and the nteract desktop app all use codemirror for syntax highlighting. Codemirror doesn't have Stata syntax highlighting yet, and I haven't taken the time to create a pr with one, though only slight modifications from the above file should be needed
from stata_kernel.
@TiesdeKok Is it OK with you if I start with your Codemirror stata.js
syntax highlighting file, modify it, and submit it as a pull request to the Codemirror repository?
from stata_kernel.
@TiesdeKok In case you wanted to give some input, I'll be working on the Stata mode on my fork of the CodeMirror repo.
from stata_kernel.
Most definitely, thanks for picking that up! I will do my best to find some time to go through it at some point as well.
from stata_kernel.
I ended up starting over from scratch. There are two ways to write a syntax highlighter for codemirror, a simple way that uses regular expressions and a complex way where you do all the low level parsing yourself. R uses the complex way, so thus your fork did as well. It was much easier to start from scratch.
from stata_kernel.
@TiesdeKok In case you wanted to test it, (and have node.js installed) you can do
git clone https://github.com/kylebarron/codemirror
cd codemirror
npm install
Then open ./mode/stata/index.html
in your web browser.
from stata_kernel.
I took an hour to look into it a little more... Since ipystata is a magic and not a kernel, you have to add that extra javascript in your code to register the syntax highlighting with the magic. In contrast, since stata_kernel is an actual kernel, I don't have to do give any extra javascript; if the highlighting file stata.js
exists in the notebook
package, then it will highlight Stata.
So even without a PR to codemirror, all I need to do is
from pkg_resources import resource_filename
path = resource_filename('notebook', 'static/components/codemirror/mode/stata/stata.js')
and then if path
doesn't exist, copy the contents of stata.js
there.
from stata_kernel.
Related Issues (20)
- Graphs do not show with stata 17 HOT 5
- Graphs not displaying on JupyterLab with Stata 17 HOT 1
- Ubuntu run pytest get "stata_path option in configuration file is missing or invalid"
- Kernel does not recover after stata process is killed
- Atom and stata_kernel togther with Hydrogen -- not executing HOT 4
- Is stata kernel able to install in Mac OS? HOT 1
- Issues with stata_kernel in Atom (Hydrogen) HOT 3
- Graph display bug after setting user _graph_keywords? HOT 34
- Update kernel's python dependencies HOT 1
- Kernel does not execute then `*` is used within multi-line `syntax` statement
- Use importlib.resources instead of pkg_resources
- Repo modernization HOT 1
- How to make jupyter automatically close the stata session HOT 1
- %help magic does not work for Stata commands HOT 2
- The word "format" appears below stata plot output
- Graphs no longer display in Jupyter notebook HOT 9
- Kernel freezes whenever I try to run some code HOT 2
- can't run arch model. HOT 2
- How can i make the results more beautiful. HOT 2
- can we insert a graph on the local path using markdown?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stata_kernel.