-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(front): refactor marked instances, configuration, and imports (#1217
) Closes: #1217
- Loading branch information
Showing
8 changed files
with
111 additions
and
89 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
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,22 @@ | ||
import { Marked, Renderer } from 'marked'; | ||
import markedAlert from 'marked-alert'; | ||
import { heading, link } from '../renderers/index.js'; | ||
|
||
const renderer = new Renderer(); | ||
renderer.link = link; | ||
renderer.heading = heading; | ||
|
||
const marker = new Marked(); | ||
marker.use(markedAlert(), { renderer: renderer, gfm: true }); | ||
|
||
// General markdown rendering function | ||
/** | ||
* Render markdown text using the marked library. | ||
* | ||
* @param {string} text - The markdown text to render. | ||
* @returns {string} - Rendered HTML content. | ||
*/ | ||
export default async function marked(text) { | ||
const content = marker.parse(text); | ||
return 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Marked, Renderer } from 'marked'; | ||
import markedAlert from 'marked-alert'; | ||
import { link, anchorHeading, image } from '../renderers/index.js'; | ||
|
||
const postRenderer = new Renderer(); | ||
postRenderer.link = link; | ||
postRenderer.heading = anchorHeading; | ||
postRenderer.image = image; | ||
|
||
const postMarker = new Marked(); | ||
postMarker.use(markedAlert(), { renderer: postRenderer, gfm: true }); | ||
|
||
// Post markdown rendering/parsing function | ||
/** | ||
* Render markdown text using the marked library. | ||
* | ||
* @param {string} text - The markdown text to render. | ||
* @returns {string} - Rendered HTML content. | ||
*/ | ||
export default async function postMarked(text) { | ||
const content = postMarker.parse(text); | ||
return 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