-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Escape hash in code/codeblocks (#504)
* Escape hash in code/codeblocks * format * pin test accelerarte
- Loading branch information
Showing
6 changed files
with
27 additions
and
11 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { replaceAsync } from "./utils.js"; | ||
|
||
// Preprocessor that converts `#` char inside code/codeblocks into its html5 entity `#` | ||
// otherwise, an extra new space was being rendered | ||
export const hashInCodePreprocess = { | ||
markup: async ({ content }) => { | ||
const REGEX_CODE_BLOCK = /```.*?```/gs; | ||
const REGEX_INLINE_CODE = /`.*?`/gs; | ||
content = await replaceAsync(content, REGEX_CODE_BLOCK, async (codeContent) => { | ||
return codeContent.replaceAll("#", "#"); | ||
}); | ||
content = await replaceAsync(content, REGEX_INLINE_CODE, async (codeContent) => { | ||
return codeContent.replaceAll("#", "#"); | ||
}); | ||
return { code: content }; | ||
}, | ||
}; |
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
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