From 0c47eeefc6bdd2b0f6c7ad65aff5761ac304c153 Mon Sep 17 00:00:00 2001 From: Zak Henry Date: Sat, 13 Jul 2019 15:37:46 +0100 Subject: [PATCH] feat(Language Support): Add Plant UML .puml support Closes #23 --- src/embedme.lib.ts | 11 +++++++++++ test/fixture.md | 14 ++++++++++++++ test/sample.puml | 6 ++++++ 3 files changed, 31 insertions(+) create mode 100644 test/sample.puml diff --git a/src/embedme.lib.ts b/src/embedme.lib.ts index 150b8cc..3ac278b 100644 --- a/src/embedme.lib.ts +++ b/src/embedme.lib.ts @@ -68,6 +68,7 @@ enum SupportedFileType { KOTLIN = 'kotlin', SCALA = 'scala', CRYSTAL = 'cr', + PLANT_UML = 'puml', } enum CommentFamily { @@ -75,6 +76,7 @@ enum CommentFamily { C, XML, HASH, + SINGLE_QUOTE, } const languageMap: Record = { @@ -106,6 +108,7 @@ const languageMap: Record = { SupportedFileType.RUBY, SupportedFileType.CRYSTAL, ], + [CommentFamily.SINGLE_QUOTE]: [SupportedFileType.PLANT_UML], }; const filetypeCommentReaders: Record = { @@ -132,6 +135,14 @@ const filetypeCommentReaders: Record = return null; } + return match[1]; + }, + [CommentFamily.SINGLE_QUOTE]: line => { + const match = line.match(/'\s*?(\S*?)$/); + if (!match) { + return null; + } + return match[1]; }, }; diff --git a/test/fixture.md b/test/fixture.md index 29295f0..d6444b6 100644 --- a/test/fixture.md +++ b/test/fixture.md @@ -290,6 +290,20 @@ object HelloWorld { ``` +Plant UML + +```puml +' sample.puml + +@startuml +Bob -> Alice : hello +activate Alice +Alice -> Alice : some action +return bye +@enduml + +``` + ## Extension-less selection ```sh diff --git a/test/sample.puml b/test/sample.puml new file mode 100644 index 0000000..fd151fb --- /dev/null +++ b/test/sample.puml @@ -0,0 +1,6 @@ +@startuml +Bob -> Alice : hello +activate Alice +Alice -> Alice : some action +return bye +@enduml