zizhongyan / StataImproved

Improved Stata Editor for macOS : a sublime text 3 plugin
MIT License
46 stars 15 forks source link

Snippets for dynamic tags in Stata 15 [Feature Request] #6

Closed pjpaulpj closed 7 years ago

pjpaulpj commented 7 years ago

Hi,

First, thanks for the great piece of code that you have developed. Makes coding in Stata a lot easier.

This is more of a feature request than an issue. Stata 15 has finally introduced support for Markdown syntax in Stata via the dyntext package. Stata's markups feature a lot of tags (similar to code chunk options in R-markdown) that control the output of the code as it appears in the converted PDF or HTML document. It would be great if you could code in snippet support for the tags to make scripting easier.

Regards,

zizhongyan commented 7 years ago

Hi PJ Paul,

I have just installed a trial version of Stata 15 today. According to my understanding, to use the stata 15 markdown, one needs to code the script in a plain text file first, and then use dyntext/markdown command to convert it.

My preliminary idea is to add a series of "dd_xxx" snippets. What do you think?

More specifically, we could add:

dd_v for: <<dd_version: ... >>

dd_dis for: <<dd_display: %4.2f `....'>>

dd_do for: <> .... <>

dd_ignore for: <> .... <>

Best regards, Zizhong

pjpaulpj commented 7 years ago

Makes sense. We should also add a snippet for the ~~~~ delimiters.

I looked up adding multiple snippets in a single file and found this link Regards,

zizhongyan commented 7 years ago

Thanks. I see. But the problem is the syntax highlighting in the txt file. Users might not want the txt file has a Stata style syntax highlighting.

pjpaulpj commented 7 years ago

Does this workaround solve that?

I just checked and verified that the scope changes to scope.stata when I set 'stata' as the language for a .txt file.

zizhongyan commented 7 years ago

Sure, this does work.

I added the snippets for stata markdown in this file: https://github.com/zizhongyan/StataImproved/blob/master/markdown.sublime-completions

please feel free to change/add if you wish. Then I will put a new release later if these are fine with you.

The scheme of syntax highlighting is also changed accordingly.

Thank you for the great suggestion!

pjpaulpj commented 7 years ago

Thanks for the great edits.

My only comment would be about the dd_tilde. Currently the completion for dd_tilde is to output one set of delimiter tildes (ie ~~~~). However, codeblocks in Stata markdown always require a pair of tildes. Perhaps, it makes sense then, to make dd_tilde output a pair of delimiter tildes, rather than just one set.

I've made a pull request to this effect.

Regards,

zizhongyan commented 7 years ago

Hi,

Sorry for the delayed response as I was a bit busy this week.

Many thanks for the pull request. I have merged your suggestion.

Btw, do you think we could simply use ~~~~ to trigger the snippet? It seems in ST3, the special character "~" cannot be used as a starting character for completion trigger..

Best wishes,