-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[![PR App][icn]][demo] | RM-10622 :-------------------:|:----------: ## 🧰 Changes Trims whitespace surrounding emphasis content. ``` ** bold ** ``` Will get serialized to: ``` **bold** ``` We should probably remove this once everything is migrated to MDX. ## 🧬 QA & Testing - [Broken on production][prod]. - [Working in this PR app][demo]. [demo]: https://markdown-pr-PR_NUMBER.herokuapp.com [prod]: https://SUBDOMAIN.readme.io [icn]: https://user-images.githubusercontent.com/886627/160426047-1bee9488-305a-4145-bb2b-09d8b757d38a.svg --------- Co-authored-by: Rafe Goldberg <[email protected]>
- Loading branch information
1 parent
036cc92
commit 45279f3
Showing
4 changed files
with
39 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Emphasis, Strong, Node } from 'mdast'; | ||
import { EXIT, SKIP, visit } from 'unist-util-visit'; | ||
import { Transform } from 'mdast-util-from-markdown'; | ||
|
||
const strongTest = (node: Node): node is Strong | Emphasis => ['emphasis', 'strong'].includes(node.type); | ||
|
||
const compatibilityTransfomer = (): Transform => tree => { | ||
const trimEmphasis = (node: Emphasis | Strong) => { | ||
visit(node, 'text', child => { | ||
child.value = child.value.trim(); | ||
return EXIT; | ||
}); | ||
|
||
return node; | ||
}; | ||
|
||
visit(tree, strongTest, node => { | ||
trimEmphasis(node); | ||
return SKIP; | ||
}); | ||
|
||
return tree; | ||
}; | ||
|
||
export default compatibilityTransfomer; |
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