Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add escape characters #452

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/markdown/MarkdownSerializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ export class MarkdownSerializerState {
// content. If `startOfLine` is true, also escape characters that
// have special meaning only at the start of the line.
esc(str, startOfLine) {
const escRegexp = this.options?.commonEscape || /[`\^+*\\\|~\[\]\{\}<>\$]/g;
const escRegexp = this.options?.commonEscape || /[`\^+*\\\|~\[\]\{\}<>\$_]/g;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add tests for this case to markdown-editor/src/core/markdown/Markdown.test.ts. What do you think?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, okay, I'll add tests

const startOfLineEscRegexp = this.options?.startOfLineEscape || /^[:#\-*+>]/;

str = str.replace(escRegexp, '\\$&');
Expand Down
Loading