jonschlinkert / sublime-markdown-extended

Top 100 Sublime Text plugin! Markdown syntax highlighter for Sublime Text, with extended support for GFM fenced code blocks, with language-specific syntax highlighting. YAML Front Matter. Works with ST2/ST3. Goes great with Assemble.
https://github.com/jonschlinkert
MIT License
660 stars 96 forks source link

Feature Request: Support Curly Brackets for Code Block #156

Open j9ac9k opened 7 years ago

j9ac9k commented 7 years ago

Attached image to highlight what I mean

example

Ideally, there would be support for Stitch, which would include some other code chunk options such as echo=False and so on.

jonschlinkert commented 7 years ago

I'd be open to discussing this, but someone with more knowledge of ST would need to implement the code chunk handling. How useful would this be without that?

j9ac9k commented 7 years ago

So I managed to modify the .sublime-syntax file (basically changed the regular expression that does the matching to get this working, but my fix is definitely far from ideal).

I changed line ~160~ 460 of the .sublime-syntax file to:

    - match: '(```|~~~|{%\s*highlight)\s*{?(python)}?\s*((?:linenos\s*)?%})?$'

So basically I just made the curly brackets option using the ?regular expression symbol. I could try and modify the regular expression to look for the curly brackets in pairs (but make them optional, but they need to be a pair of open and closed.

I guess, ideally, there would be more pandoc functionality, however this library is not meant to support pandoc necessarily ..thats just my use case.

HenrikEckermann commented 6 years ago

@jonschlinkert 👍 Thanks for your work man!

Regarding this issue: knitr will soon enable that Python code chunks can be used like r code chunks. This possible now but the memory is not kept between code cells, which makes it useless for scientific reporting (unless you really want to import/export files again and again.

So, many people including myself will then use rmakdown also for python as primary reporting tool. For that work really well the curly brackets are necessary because on with them you can control output through knitr. So, it would be very nice if this could be added somehow.

@j9ac9k , did the above fix just work for you without any issues?

j9ac9k commented 6 years ago

@HenrikEckermann I haven't been doing as much markdown with python work recently for my academic work, but the regular expression adjustment I made before did fix my issue at the time, but I didn't attempt to pass in any of the other optional parameters (like echo=False, include=True), which I imagine won't work at all.

Given that RMarkdown has lots of overlap with Pandoc flavored markdown, I'm not sure if Markdown Extended is the right plugin to expect to use with RMarkdown. The package maintainers have been resistant to implementing the YAML header and other features that are unique to Pandoc flavored markdown/RMarkdown.

https://github.com/jonschlinkert/sublime-markdown-extended/issues/128

https://github.com/jonschlinkert/sublime-markdown-extended/issues/169

HenrikEckermann commented 6 years ago

Thanks man! Do you maybe have any other suggestions which package to use then if I am used to Rmarkdown? I guess I have to stick with Rmarkdown if I want to use knitr, right? Let me know if you know a better package for that.

j9ac9k commented 6 years ago

I typically have been using Pandoc more so than RMarkdown/Knitr, so my workflow has been structured to go around that.... but when I was doing Knitr related work, I would break it up into using this extension for getting most of the contents/code in place, then would use RStudio for the rest, not ideal but it works.