Tidy regex to capture filename
This commit is contained in:
parent
338062016c
commit
7e0b4e4fb7
1 changed files with 6 additions and 5 deletions
|
|
@ -25,11 +25,12 @@ function asBasicISOString(date: Date): string {
|
|||
function reformatCodeBlocks(msgText: string): string {
|
||||
const codeBlockRegex = /```(.*?\.(\w+)\s*.*)\n/g;
|
||||
|
||||
return msgText.replace(codeBlockRegex, (match, metadata, extension) => {
|
||||
const filename = metadata.split(" ")[0];
|
||||
const lang = languageForFilepath(filename);
|
||||
return `\`\`\`${extension}\n${lang.comment} ${metadata}\n`;
|
||||
});
|
||||
return msgText.replace(codeBlockRegex,
|
||||
(match, metadata, filename, extension) => {
|
||||
const lang = languageForFilepath(filename);
|
||||
return `\`\`\`${extension}\n${lang.comment} ${metadata}\n`;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
const ShareSlashCommand: SlashCommand = {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue