Ensure adjacent codeblocks separated by newline
This commit is contained in:
parent
b82ccb76ad
commit
2565fa4f41
1 changed files with 4 additions and 3 deletions
|
|
@ -23,14 +23,15 @@ function asBasicISOString(date: Date): string {
|
|||
}
|
||||
|
||||
function reformatCodeBlocks(msgText: string): string {
|
||||
const codeBlockRegex = /```((.*?\.(\w+))\s*.*)\n/g;
|
||||
|
||||
return msgText.replace(codeBlockRegex,
|
||||
const codeBlockFenceRegex = /```((.*?\.(\w+))\s*.*)\n/g;
|
||||
msgText = msgText.replace(codeBlockFenceRegex,
|
||||
(match, metadata, filename, extension) => {
|
||||
const lang = languageForFilepath(filename);
|
||||
return `\`\`\`${extension}\n${lang.comment} ${metadata}\n`;
|
||||
},
|
||||
);
|
||||
// Appease the markdown linter
|
||||
return msgText.replace(/```\n```/g, '```\n\n```');
|
||||
}
|
||||
|
||||
const ShareSlashCommand: SlashCommand = {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue