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

Handles various Discord markdowns #114

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

arx-ein
Copy link
Contributor

@arx-ein arx-ein commented Mar 4, 2022

Discord markdown の記号が読まれないように

@arx-ein arx-ein linked an issue Mar 4, 2022 that may be closed by this pull request
@arx-ein arx-ein requested a review from phenylshima March 4, 2022 07:31
Copy link
Collaborator

@phenylshima phenylshima left a comment

Choose a reason for hiding this comment

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

今回追加したreplacerに対応するテストを書いてください。

Comment on lines +21 to +22
const MARKDOWN2_REPLACER = [/([*_~`])\1(.+?)\1\1/gs, '$2 '] as const;
const MARKDOWN1_REPLACER = [/([_`])(.+?)\1/gs, '$2 '] as const;
Copy link
Collaborator

Choose a reason for hiding this comment

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

/([*_~`]{2}|[_`])(.+?)\1/gs

とすれば一つにまとめられるのでは?

const MARKDOWN1_REPLACER = [/([_`])(.+?)\1/gs, '$2 '] as const;
const ITALIC_REPLACER = [/\*(.+?)\*/g, '$1 '] as const;
// eslint-disable-next-line no-irregular-whitespace
const QUOTE_REPLACER = [/^> (.*[^\s ])$/g, '$1 '] as const;
Copy link
Collaborator

Choose a reason for hiding this comment

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

これだと末尾に空白文字のある行だけが置換されません。
例:

> a 
> b

(> aの行の末尾にだけスペースがある)
だと、> bの行はマッチしますが、> aの行はマッチしません。

@arx-ein
Copy link
Contributor Author

arx-ein commented Mar 4, 2022

今回追加したreplacerに対応するテストを書いてください。

@femshima (略).test.js にということでよろしいですか?

@cm-ayf
Copy link
Member

cm-ayf commented Mar 12, 2022

@arx-ein リマインド.

@cm-ayf cm-ayf marked this pull request as draft April 3, 2022 03:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace >>>, ~~, *, and **
3 participants