microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.47k stars 28.63k forks source link

Better choices in snippets of fenced code blocks #157419

Closed Yarakashi-Kikohshi closed 2 years ago

Yarakashi-Kikohshi commented 2 years ago

This issue is about Markdown.

The choice of languages in the fenced code block snippet provided by default seems selfish.

https://github.com/microsoft/vscode/blob/e58c66c819a9739dc3d70e04943db03f213c3735/extensions/markdown-basics/snippets/markdown.code-snippets#L22-L26

I think that the languages that can be selected with these should be languages that allow syntax highlighting in the editor, or languages that can be syntax highlighted in the previewer (highlight.js).

In fact, I don't know which list should be the default, but it is not reasonable to include only languages that someone would use frequently as options.

If you agree with this opinion and have any suggestions as to which list would be better, I will revise the snippet and make a pull request.

Lists of language aliases for fenced code block

I've extracted and listed the language and aliases for each. All of lists are in alphabetical order.

List of language aliases by tmLanguage.json (editor)

https://github.com/microsoft/vscode/blob/main/extensions/markdown-basics/syntaxes/markdown.tmLanguage.json

I used the following regular expression to extract language aliases:

\?i:\(.+?\)

language aliases (191):

.textmate_init,Appraisals,aw,bash_login,bash_logout,bash_profile,bash,bashrc,bat,batch,Berksfile,Berksfile.lock,bibtex,bsh,c,c#,c++,Cakefile,Capfile,cgi,Cheffile,cjs,clj,cljs,clojure,coffee,coffee.erb,COMMIT_EDITMSG,conf,cpp,cpt,cpy,cs,csharp,css,css.erb,ctp,cxx,dart,dataviewjs,ddl,diff,dml,dockerfile,Dockerfile,dtml,elixir,erlang,es6,f#,fcgi,fs,fsharp,Gemfile,gemspec,git-rebase-todo,GNUmakefile,go,golang,groovy,Guardfile,gvy,gyp,gypi,h,handlebars,hbs,Hobofile,htm,html,inc,ini,irbrc,jade,java,javascript,js,json,json5,jsonc,jsp,jsx,julia,latex,less,log,lua,m,makefile,Makefile,markdown,md,MERGE_MSG,mjs,mm,nqp,obj-c,objc,objective-c,objectivec,OCamlMakefile,opml,p6,patch,perl,perl6,php,php3,php4,php5,phpt,phtml,pl,PL,pl6,pm,pm6,pod,powershell,prawn,profile,ps1,psd1,psgi,psm1,pt,pug,Puppetfile,py,py3,python,pyw,r,R,rake,Rakefile,Rantfile,rb,rbx,re,regexp,rej,rjs,Rprofile,rpy,rs,rss,ru,ruby,rust,s,S,sbt,scala,SConscript,sconstruct,Sconstruct,SConstruct,scss,sh,shell,shtml,sql,sublime-build,sublime-completions,sublime-keymap,sublime-menu,sublime-mousemap,sublime-project,sublime-settings,sublime-theme,swift,t,tex,Thorfile,tld,tmpl,tpl,ts,tsx,typescript,Vagrantfile,vb,vcl,xhtml,xml,xsd,xsl,xslt,yaml,yml,zsh,

However, it does not include: This is because you cannot use regular expressions in snippets.

\\{\\.bash.+?\\},\\{\\.js.+?\\},\\{\\.julia.+?\\},\\{\\.python.+?\\},\\{\\.r.+?\\},\\{\\.rust.+?\\},

List of language aliases by highlight.js (previewer)

https://github.com/highlightjs/highlight.js/blob/main/SUPPORTED_LANGUAGES.md

language aliases (396):

1c,4d,abap,abnf,accesslog,actionscript,ada,adoc,alan,angelscript,apache,apacheconf,apex,applescript,arcade,arduino,arm,armasm,as,asc,asciidoc,aspectj,atom,autohotkey,autoit,avrasm,awk,axapta,bash,basic,bat,bbcode,bf,bind,blade,bnf,brainfuck,c,c++,cal,capnp,capnproto,cc,chaos,chapel,chpl,cisco,clj,clojure,cls,cmake,cmake.in,cmd,cobol,coffee,coffeescript,console,coq,cos,cpc,cpp,cr,craftcms,crm,crmsh,crystal,cs,csharp,cshtml,cson,csp,css,curl,cxx,cypher,d,dafny,dart,dfm,diff,django,dns,docker,dockerfile,dos,dpr,dsconfig,dst,dts,dust,dylan,ebnf,elixir,elm,erl,erlang,excel,extempore,f90,f95,fix,fortran,fs,fsharp,gams,gauss,gawk,gcode,gdscript,gemspec,gf,gherkin,glimmer,glsl,gms,gn,gni,go,godot,golang,golo,gololang,gradle,graph,graphql,groovy,gsql,gss,gyp,h,h++,haml,handlebars,haskell,haxe,hbs,hcl,hh,hlsl,hpp,hs,html,html.handlebars,html.hbs,htmlbars,http,https,hx,hxx,hy,hylang,i,i7,iced,iecst,inform7,ini,ino,instances,iol,irb,irpf90,java,javascript,jinja,jolie,js,json,jsp,jsx,julia-repl,julia,k,kaos,kdb,kotlin,kt,lasso,lassoscript,ldif,leaf,lean,less,lisp,livecodeserver,livescript,ln,ls,lua,macaulay2,mak,make,makefile,markdown,mathematica,matlab,mawk,maxima,md,mel,mercury,mirc,mizar,mk,mkb,mkd,mkdown,ml,mlir,mm,mma,mojolicious,monkey,moon,moonscript,mrc,n1ql,nawk,nc,never,nginx,nginxconf,nim,nimrod,nix,nsis,oak,obj-c,obj-c++,objc,objective-c++,objectivec,ocaml,ocl,ol,openscad,osascript,oxygene,p21,papyrus,parser3,pas,pascal,patch,pcmk,perl,pf,pf.conf,pgsql,php,pine,pinescript,pl,plaintext,plist,pm,podspec,pony,postgres,postgresql,powershell,pp,prg,processing,profile,prolog,properties,protobuf,ps,ps1,psc,puppet,py,pycon,python-repl,python,qml,qsharp,r,razor-cshtml,razor,rb,re,reasonml,rebol,red-system,red,redbol,rf,rib,risc,riscript,robot,rpm-spec,rpm-specfile,rpm,rs,rsl,rss,ruby,ruleslanguage,rust,sap-abap,sas,SAS,sc,scad,scala,scheme,sci,scilab,scl,scss,sh,shell,shexc,smali,smalltalk,sml,sol,solidity,spec,specfile,spl,sql,st,stan,standard-cobol,stanfuncs,stata,step,stl,stp,structured-text,styl,stylus,subunit,supercollider,svelte,svg,swift,tao,tap,tcl,terraform,tex,text,tf,thor,thrift,tk,toit,toml,tp,ts,tsql,twig,txt,typescript,unicorn-rails-log,v,vala,vb,vba,vbnet,vbs,vbscript,verilog,vhdl,vim,wl,x++,x86asm,xhtml,xjb,xl,xls,xlsx,xml,xpath,xq,xquery,xs,xsd,xsharp,xsl,xtlang,xtm,yaml,yml,zenscript,zep,zephir,zone,zs,zsh,

Combined list of the above two

Because the two lists above do not match exactly, I also created a list that combines the above two. Duplicate aliases was merged into one.

language aliases (508):

.textmate_init,1c,4d,abap,abnf,accesslog,actionscript,ada,adoc,alan,angelscript,apache,apacheconf,apex,applescript,Appraisals,arcade,arduino,arm,armasm,as,asc,asciidoc,aspectj,atom,autohotkey,autoit,avrasm,aw,awk,axapta,bash_login,bash_logout,bash_profile,bash,bashrc,basic,bat,batch,bbcode,Berksfile,Berksfile.lock,bf,bibtex,bind,blade,bnf,brainfuck,bsh,c,c#,c++,Cakefile,cal,Capfile,capnp,capnproto,cc,cgi,chaos,chapel,Cheffile,chpl,cisco,cjs,clj,cljs,clojure,cls,cmake,cmake.in,cmd,cobol,coffee,coffee.erb,coffeescript,COMMIT_EDITMSG,conf,console,coq,cos,cpc,cpp,cpt,cpy,cr,craftcms,crm,crmsh,crystal,cs,csharp,cshtml,cson,csp,css,css.erb,ctp,curl,cxx,cypher,d,dafny,dart,dataviewjs,ddl,dfm,diff,django,dml,dns,docker,dockerfile,Dockerfile,dos,dpr,dsconfig,dst,dtml,dts,dust,dylan,ebnf,elixir,elm,erl,erlang,es6,excel,extempore,f#,f90,f95,fcgi,fix,fortran,fs,fsharp,gams,gauss,gawk,gcode,gdscript,Gemfile,gemspec,gf,gherkin,git-rebase-todo,glimmer,glsl,gms,gn,gni,GNUmakefile,go,godot,golang,golo,gololang,gradle,graph,graphql,groovy,gsql,gss,Guardfile,gvy,gyp,gypi,h,h++,haml,handlebars,haskell,haxe,hbs,hcl,hh,hlsl,Hobofile,hpp,hs,htm,html,html.handlebars,html.hbs,htmlbars,http,https,hx,hxx,hy,hylang,i,i7,iced,iecst,inc,inform7,ini,ino,instances,iol,irb,irbrc,irpf90,jade,java,javascript,jinja,jolie,js,json,json5,jsonc,jsp,jsx,julia-repl,julia,k,kaos,kdb,kotlin,kt,lasso,lassoscript,latex,ldif,leaf,lean,less,lisp,livecodeserver,livescript,ln,log,ls,lua,m,macaulay2,mak,make,makefile,Makefile,markdown,mathematica,matlab,mawk,maxima,md,mel,mercury,MERGE_MSG,mirc,mizar,mjs,mk,mkb,mkd,mkdown,ml,mlir,mm,mma,mojolicious,monkey,moon,moonscript,mrc,n1ql,nawk,nc,never,nginx,nginxconf,nim,nimrod,nix,nqp,nsis,oak,obj-c,obj-c++,objc,objective-c,objective-c++,objectivec,ocaml,OCamlMakefile,ocl,ol,openscad,opml,osascript,oxygene,p21,p6,papyrus,parser3,pas,pascal,patch,pcmk,perl,perl6,pf,pf.conf,pgsql,php,php3,php4,php5,phpt,phtml,pine,pinescript,pl,PL,pl6,plaintext,plist,pm,pm6,pod,podspec,pony,postgres,postgresql,powershell,pp,prawn,prg,processing,profile,prolog,properties,protobuf,ps,ps1,psc,psd1,psgi,psm1,pt,pug,puppet,Puppetfile,py,py3,pycon,python-repl,python,pyw,qml,qsharp,r,R,rake,Rakefile,Rantfile,razor-cshtml,razor,rb,rbx,re,reasonml,rebol,red-system,red,redbol,regexp,rej,rf,rib,risc,riscript,rjs,robot,rpm-spec,rpm-specfile,rpm,Rprofile,rpy,rs,rsl,rss,ru,ruby,ruleslanguage,rust,s,S,sap-abap,sas,SAS,sbt,sc,scad,scala,scheme,sci,scilab,scl,SConscript,sconstruct,Sconstruct,SConstruct,scss,sh,shell,shexc,shtml,smali,smalltalk,sml,sol,solidity,spec,specfile,spl,sql,st,stan,standard-cobol,stanfuncs,stata,step,stl,stp,structured-text,styl,stylus,sublime-build,sublime-completions,sublime-keymap,sublime-menu,sublime-mousemap,sublime-project,sublime-settings,sublime-theme,subunit,supercollider,svelte,svg,swift,t,tao,tap,tcl,terraform,tex,text,tf,thor,Thorfile,thrift,tk,tld,tmpl,toit,toml,tp,tpl,ts,tsql,tsx,twig,txt,typescript,unicorn-rails-log,v,Vagrantfile,vala,vb,vba,vbnet,vbs,vbscript,vcl,verilog,vhdl,vim,wl,x++,x86asm,xhtml,xjb,xl,xls,xlsx,xml,xpath,xq,xquery,xs,xsd,xsharp,xsl,xslt,xtlang,xtm,yaml,yml,zenscript,zep,zephir,zone,zs,zsh,

In this case as well it does not include:

\\{\\.bash.+?\\},\\{\\.js.+?\\},\\{\\.julia.+?\\},\\{\\.python.+?\\},\\{\\.r.+?\\},\\{\\.rust.+?\\},

Version

 Version: 1.69.2 (user setup)
  Commit: 3b889b090b5ad5793f524b5d1d39fda662b96a2a
    Date: 2022-07-18T16:12:52.460Z
Electron: 18.3.5
Chromium: 100.0.4896.160
 Node.js: 16.13.2
      V8: 10.0.139.17-electron.0
      OS: Windows_NT x64 10.0.22000
mjbvz commented 2 years ago

The current snippet has most of the most commonly used languages. You can type out whatever additional language you wish to use (or even add your own snippet for it)