Skip to content

Commit

Permalink
Merge pull request #26 from zakhenry/feat/suppot-plantuml
Browse files Browse the repository at this point in the history
feat(Language Support): Add Plant UML .puml support
  • Loading branch information
zakhenry authored Jul 13, 2019
2 parents b400f05 + 0c47eee commit b2fa8b0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/embedme.lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,15 @@ enum SupportedFileType {
KOTLIN = 'kotlin',
SCALA = 'scala',
CRYSTAL = 'cr',
PLANT_UML = 'puml',
}

enum CommentFamily {
NONE, // some languages do not support comments, e.g. JSON
C,
XML,
HASH,
SINGLE_QUOTE,
}

const languageMap: Record<CommentFamily, SupportedFileType[]> = {
Expand Down Expand Up @@ -106,6 +108,7 @@ const languageMap: Record<CommentFamily, SupportedFileType[]> = {
SupportedFileType.RUBY,
SupportedFileType.CRYSTAL,
],
[CommentFamily.SINGLE_QUOTE]: [SupportedFileType.PLANT_UML],
};

const filetypeCommentReaders: Record<CommentFamily, FilenameFromCommentReader> = {
Expand All @@ -132,6 +135,14 @@ const filetypeCommentReaders: Record<CommentFamily, FilenameFromCommentReader> =
return null;
}

return match[1];
},
[CommentFamily.SINGLE_QUOTE]: line => {
const match = line.match(/'\s*?(\S*?)$/);
if (!match) {
return null;
}

return match[1];
},
};
Expand Down
14 changes: 14 additions & 0 deletions test/fixture.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions test/sample.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@startuml
Bob -> Alice : hello
activate Alice
Alice -> Alice : some action
return bye
@enduml

0 comments on commit b2fa8b0

Please sign in to comment.