Skip to content

Commit

Permalink
Remove escape when inserting markdown snippet to markdown file (elyra…
Browse files Browse the repository at this point in the history
  • Loading branch information
Martha Cryan authored and lresende committed Jul 15, 2020
1 parent 5befb77 commit 5686dcb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/code-snippet/src/CodeSnippetWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ class CodeSnippetDisplay extends React.Component<ICodeSnippetDisplayProps> {
const documentWidget = widget as DocumentWidget;
const fileEditor = (documentWidget.content as FileEditor).editor;
const markdownRegex = /^\.(md|mkdn?|mdown|markdown)$/;
if (PathExt.extname(widget.context.path).match(markdownRegex) !== null) {
if (
PathExt.extname(widget.context.path).match(markdownRegex) !== null &&
snippet.language.toLowerCase() !== 'markdown'
) {
// Wrap snippet into a code block when inserting it into a markdown file
fileEditor.replaceSelection(
'```' + snippet.language + '\n' + snippetStr + '\n```'
Expand All @@ -118,7 +121,10 @@ class CodeSnippetDisplay extends React.Component<ICodeSnippetDisplayProps> {
kernelLanguage,
notebookCellEditor
);
} else if (notebookCell instanceof MarkdownCell) {
} else if (
notebookCell instanceof MarkdownCell &&
snippet.language.toLowerCase() !== 'markdown'
) {
// Wrap snippet into a code block when inserting it into a markdown cell
notebookCellEditor.replaceSelection(
'```' + snippet.language + '\n' + snippetStr + '\n```'
Expand Down

0 comments on commit 5686dcb

Please sign in to comment.