Skip to content

Commit

Permalink
fix(Lib): Relax regex on extension mapping to support more complex types
Browse files Browse the repository at this point in the history
Relates to #30
  • Loading branch information
zak-cloudnc committed Jul 13, 2019
1 parent 6eed222 commit 7a2ac3b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/embedme.lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,15 @@ function getReplacement(
return substr;
}

if (!codeExtension) {
log({ returnSnippet: substr }, chalk.blue(`No code extension detected, skipping code block...`));
return substr;
}

let commentedFilename: string | null;
if (commentEmbedOverrideFilepath) {
commentedFilename = commentEmbedOverrideFilepath;
} else {
if (!codeExtension) {
log({ returnSnippet: substr }, chalk.blue(`No code extension detected, skipping code block...`));
return substr;
}

if (!firstLine) {
log({ returnSnippet: substr }, chalk.blue(`Code block is empty & no preceding embedme comment, skipping...`));
return substr;
Expand Down Expand Up @@ -346,7 +346,7 @@ function getReplacement(
return substr;
}

const chalkColour = options.verify ? 'red' : 'green';
const chalkColour = options.verify ? 'yellow' : 'green';

log(
{ returnSnippet: replacement },
Expand Down Expand Up @@ -383,7 +383,7 @@ export function embedme(sourceText: string, inputFilePath: string, options: Embe
const [codeFence, leadingSpaces] = result;
const start = sourceText.substring(previousEnd, result.index);

const extensionMatch = codeFence.match(/```(\S*)/);
const extensionMatch = codeFence.match(/```(.*)/);

const codeExtension = extensionMatch ? extensionMatch[1] : null;
const splitFence = codeFence.split('\n');
Expand Down
2 changes: 1 addition & 1 deletion test/fixture.md
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ export function hello(): string {

<!-- embedme sample.json -->

```{.json
```{.json caption="Some JSON file"}
{
"hello": "world"
}
Expand Down

0 comments on commit 7a2ac3b

Please sign in to comment.