-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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: convert by using HTML tag when it is not between spaces #2572
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d22044a
wip: convert strong to tag when it is not between spaces
jajugoguma 627996a
fix: convert strong to tag when it is not between spaces
jajugoguma 11a4b4c
fix: convertor that follows the same rule
jajugoguma 159e47a
test: add test for convertor
jajugoguma 9dd5e9e
chore: apply code reviews
jajugoguma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -208,29 +208,50 @@ export const toMdConvertors: ToMdConvertorMap = { | |
}; | ||
}, | ||
|
||
strong({ node }, { entering }) { | ||
strong({ node }, { entering }, betweenSpace) { | ||
const { rawHTML } = node.attrs; | ||
let delim; | ||
|
||
if (betweenSpace) { | ||
delim = '**'; | ||
} else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
let delim = '**';
if (!betweenSpace) {
delim = entering ? '<strong>' : '</strong>';
} |
||
delim = entering ? '<strong>' : '</strong>'; | ||
} | ||
|
||
return { | ||
delim: '**', | ||
delim, | ||
rawHTML: entering ? getOpenRawHTML(rawHTML) : getCloseRawHTML(rawHTML), | ||
}; | ||
}, | ||
|
||
emph({ node }, { entering }) { | ||
emph({ node }, { entering }, betweenSpace) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 같이 처리했네요. 좋습니다. 👍👍👍 |
||
const { rawHTML } = node.attrs; | ||
let delim; | ||
|
||
if (betweenSpace) { | ||
delim = '*'; | ||
} else { | ||
delim = entering ? '<em>' : '</em>'; | ||
} | ||
|
||
return { | ||
delim: '*', | ||
delim, | ||
rawHTML: entering ? getOpenRawHTML(rawHTML) : getCloseRawHTML(rawHTML), | ||
}; | ||
}, | ||
|
||
strike({ node }, { entering }) { | ||
strike({ node }, { entering }, betweenSpace) { | ||
const { rawHTML } = node.attrs; | ||
let delim; | ||
|
||
if (betweenSpace) { | ||
delim = '~~'; | ||
} else { | ||
delim = entering ? '<del>' : '</del>'; | ||
} | ||
|
||
return { | ||
delim: '~~', | ||
delim, | ||
rawHTML: entering ? getOpenRawHTML(rawHTML) : getCloseRawHTML(rawHTML), | ||
}; | ||
}, | ||
|
@@ -353,7 +374,7 @@ function createMarkTypeConvertors(convertors: ToMdConvertorMap) { | |
const markTypes = Object.keys(markTypeOptions) as WwMarkType[]; | ||
|
||
markTypes.forEach((type) => { | ||
markTypeConvertors[type] = (nodeInfo, entering) => { | ||
markTypeConvertors[type] = (nodeInfo, entering, betweenSpace) => { | ||
const markOption = markTypeOptions[type]; | ||
const convertor = convertors[type]; | ||
|
||
|
@@ -362,7 +383,9 @@ function createMarkTypeConvertors(convertors: ToMdConvertorMap) { | |
// When calling the converter without using `delim` and `rawHTML` values, | ||
// the converter is called without parameters. | ||
const runConvertor = convertor && nodeInfo && !isUndefined(entering); | ||
const params = runConvertor ? convertor!(nodeInfo as MarkInfo, { entering }) : {}; | ||
const params = runConvertor | ||
? convertor!(nodeInfo as MarkInfo, { entering }, betweenSpace) | ||
: {}; | ||
|
||
return { ...params, ...markOption }; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
기본값으로 처리한
'a'
는 공백 문자를 넣으면isEndWithSpace
혹은isStartWithSpace
가 제대로 동작하지 않으니까 임의로 넣은 문자인가요?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그러게요.
'a'
가 뭘 나타내는건지 의미를 만들어 상수화 시켜야겠습니다.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵, 해당 문자 의미 만들어서 상수화 했습니다.