sublime-markdown-extended icon indicating copy to clipboard operation
sublime-markdown-extended copied to clipboard

Feature Request: Support Curly Brackets for Code Block

Open j9ac9k opened this issue 7 years ago • 6 comments

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.

j9ac9k avatar Jan 19 '17 04:01 j9ac9k

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?

jonschlinkert avatar Mar 02 '17 08:03 jonschlinkert

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.

j9ac9k avatar Mar 02 '17 17:03 j9ac9k

@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?

HenrikEckermann avatar Dec 20 '17 07:12 HenrikEckermann

@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

j9ac9k avatar Dec 20 '17 15:12 j9ac9k

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.

HenrikEckermann avatar Dec 20 '17 15:12 HenrikEckermann

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.

j9ac9k avatar Dec 20 '17 15:12 j9ac9k