diff --git a/integrationTests/snip/expected/sample.snippet.c-test.c b/integrationTests/snip/expected/sample.snippet.c-test.c new file mode 100644 index 00000000..dcfb86bc --- /dev/null +++ b/integrationTests/snip/expected/sample.snippet.c-test.c @@ -0,0 +1,5 @@ +#include +int main() { + printf("Hello, World!"); + return 0; +} diff --git a/integrationTests/snip/expected/sample.snippet.go-test.go b/integrationTests/snip/expected/sample.snippet.go-test.go new file mode 100644 index 00000000..50382185 --- /dev/null +++ b/integrationTests/snip/expected/sample.snippet.go-test.go @@ -0,0 +1,6 @@ +import "fmt" + +func main() { + fmt.Println("hello world") +} + diff --git a/integrationTests/snip/expected/sample.snippet.php-test.php b/integrationTests/snip/expected/sample.snippet.php-test.php new file mode 100644 index 00000000..b9f1d5be --- /dev/null +++ b/integrationTests/snip/expected/sample.snippet.php-test.php @@ -0,0 +1,3 @@ + diff --git a/integrationTests/snip/expected/sample.snippet.python-test.py b/integrationTests/snip/expected/sample.snippet.python-test.py new file mode 100644 index 00000000..a3bd307b --- /dev/null +++ b/integrationTests/snip/expected/sample.snippet.python-test.py @@ -0,0 +1 @@ +print("This line will be printed.") diff --git a/integrationTests/snip/expected/sample.snippet.ruby-test.rb b/integrationTests/snip/expected/sample.snippet.ruby-test.rb new file mode 100644 index 00000000..b85a0422 --- /dev/null +++ b/integrationTests/snip/expected/sample.snippet.ruby-test.rb @@ -0,0 +1 @@ +puts "Hello World" diff --git a/integrationTests/snip/expected/sample.snippet.rust-test.rs b/integrationTests/snip/expected/sample.snippet.rust-test.rs new file mode 100644 index 00000000..47ad8c63 --- /dev/null +++ b/integrationTests/snip/expected/sample.snippet.rust-test.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello World!"); +} diff --git a/integrationTests/snip/expected/sample.snippet.sc-test.sc b/integrationTests/snip/expected/sample.snippet.sc-test.sc new file mode 100644 index 00000000..5db496d2 --- /dev/null +++ b/integrationTests/snip/expected/sample.snippet.sc-test.sc @@ -0,0 +1,5 @@ +object Hello { + def main(args: Array[String]) = { + println("Hello, world") + } +} diff --git a/integrationTests/snip/expected/sample.snippet.scala-test.scala b/integrationTests/snip/expected/sample.snippet.scala-test.scala new file mode 100644 index 00000000..5db496d2 --- /dev/null +++ b/integrationTests/snip/expected/sample.snippet.scala-test.scala @@ -0,0 +1,5 @@ +object Hello { + def main(args: Array[String]) = { + println("Hello, world") + } +} diff --git a/integrationTests/snip/input/sample.c b/integrationTests/snip/input/sample.c new file mode 100644 index 00000000..a3a6a0b0 --- /dev/null +++ b/integrationTests/snip/input/sample.c @@ -0,0 +1,8 @@ +// :snippet-start: c-test +#include +int main() { + // printf() displays the string inside quotation // :remove: + printf("Hello, World!"); + return 0; +} +// :snippet-end: \ No newline at end of file diff --git a/integrationTests/snip/input/sample.go b/integrationTests/snip/input/sample.go new file mode 100644 index 00000000..92327c69 --- /dev/null +++ b/integrationTests/snip/input/sample.go @@ -0,0 +1,11 @@ +package main + +// :snippet-start: go-test +import "fmt" + +func main() { + // To FMT or LOG, *that* is the question // :remove: + fmt.Println("hello world") +} + +// :snippet-end: diff --git a/integrationTests/snip/input/sample.php b/integrationTests/snip/input/sample.php new file mode 100644 index 00000000..7f499b68 --- /dev/null +++ b/integrationTests/snip/input/sample.php @@ -0,0 +1,6 @@ +// :snippet-start: php-test +# Sometimes comments start with octothorps :remove: + +// :snippet-end: \ No newline at end of file diff --git a/integrationTests/snip/input/sample.py b/integrationTests/snip/input/sample.py new file mode 100644 index 00000000..896ce275 --- /dev/null +++ b/integrationTests/snip/input/sample.py @@ -0,0 +1,4 @@ +# :snippet-start: python-test +# My comment is the coolest, for real. :remove: +print("This line will be printed.") +# :snippet-end: \ No newline at end of file diff --git a/integrationTests/snip/input/sample.rb b/integrationTests/snip/input/sample.rb new file mode 100644 index 00000000..eb01d0ad --- /dev/null +++ b/integrationTests/snip/input/sample.rb @@ -0,0 +1,3 @@ +# :snippet-start: ruby-test +puts "Hello World" +# :snippet-end: \ No newline at end of file diff --git a/integrationTests/snip/input/sample.rs b/integrationTests/snip/input/sample.rs new file mode 100644 index 00000000..f060bc45 --- /dev/null +++ b/integrationTests/snip/input/sample.rs @@ -0,0 +1,6 @@ +// :snippet-start: rust-test +fn main() { + // Print text to the console. This is a boring comment. :remove: + println!("Hello World!"); +} +// :snippet-end: \ No newline at end of file diff --git a/integrationTests/snip/input/sample.sc b/integrationTests/snip/input/sample.sc new file mode 100644 index 00000000..06186e46 --- /dev/null +++ b/integrationTests/snip/input/sample.sc @@ -0,0 +1,8 @@ +// :snippet-start: sc-test +object Hello { + // Arrrrrrrrrrgs! :remove: + def main(args: Array[String]) = { + println("Hello, world") + } +} +// :snippet-end: \ No newline at end of file diff --git a/integrationTests/snip/input/sample.scala b/integrationTests/snip/input/sample.scala new file mode 100644 index 00000000..5853eaf0 --- /dev/null +++ b/integrationTests/snip/input/sample.scala @@ -0,0 +1,8 @@ +// :snippet-start: scala-test +object Hello { + // Why do we pass arguments - that sounds confrontational. :remove: + def main(args: Array[String]) = { + println("Hello, world") + } +} +// :snippet-end: diff --git a/src/bluehawk/actions/snip.ts b/src/bluehawk/actions/snip.ts index 3b54fb28..89fdb143 100644 --- a/src/bluehawk/actions/snip.ts +++ b/src/bluehawk/actions/snip.ts @@ -87,15 +87,24 @@ export const formatInRst = async ( // nasty hack to cover the suffixes/rst languages we use most often // TODO: switch to a better mapping const rstLanguageMap: Map = new Map([ + [".c", "c"], [".cpp", "cpp"], [".cs", "csharp"], + [".go", "golang"], [".gradle", "groovy"], + [".ipynb", "python"], [".java", "java"], [".js", "javascript"], [".jsx", "javascript"], [".json", "json"], [".kt", "kotlin"], [".m", "objectivec"], + [".php", "php"], + [".py", "python"], + [".rb", "ruby"], + [".rs", "rust"], + [".sc", "scala"], + [".scala", "scala"], [".swift", "swift"], [".ts", "typescript"], [".tsx", "typescript"], diff --git a/src/bluehawk/getBluehawk.ts b/src/bluehawk/getBluehawk.ts index 4b9bdf06..2dde9f9c 100644 --- a/src/bluehawk/getBluehawk.ts +++ b/src/bluehawk/getBluehawk.ts @@ -52,24 +52,27 @@ export const getBluehawk = async (): Promise => { ".c", ".cpp", ".cs", + ".dart", + ".go", + ".gradle", + ".groovy", + ".gsh", + ".gvy", + ".gy", ".h", ".hpp", - ".kt", ".java", ".js", - ".dart", ".jsx", + ".kt", ".m", ".mm", + ".rs", + ".sc", + ".scala", ".swift", ".ts", ".tsx", - ".gradle", - ".groovy", - ".gvy", - ".gy", - ".gsh", - ".go", ], { languageId: "C-like", @@ -78,8 +81,18 @@ export const getBluehawk = async (): Promise => { } ); - // Add all supported extensions here. - bluehawk.addLanguage([".py"], { + bluehawk.addLanguage([".php"], { + languageId: "PHP", + lineComments: [/# ?/], + stringLiterals: [ + { + pattern: tokens.PYTHON_STRING_LITERAL_PATTERN, + multiline: true, + }, + ], + }); + + bluehawk.addLanguage([".py", ".ipynb"], { languageId: "Python", lineComments: [/# ?/], stringLiterals: [ @@ -90,6 +103,17 @@ export const getBluehawk = async (): Promise => { ], }); + bluehawk.addLanguage([".rb"], { + languageId: "Ruby", + lineComments: [/# ?/], + stringLiterals: [ + { + pattern: tokens.PYTHON_STRING_LITERAL_PATTERN, + multiline: true, + }, + ], + }); + bluehawk.addLanguage(["", ".txt", ".rst", ".md", ".json"], { languageId: "text", });