How to parse \n #229
Unanswered
petrvecera
asked this question in
Q&A
Replies: 1 comment
-
You can simply write a plugin to process https://jsbin.com/wuhuhobuyu/edit?html,console,output const source = "[img]{STEAM_CLAN_IMAGE}/40883127/ee066fb7facac18cc377db8c9fd3bda8a80abb20.jpg[/img]\n\n\nYou can find the full patch notes [url=https://coh3.companyofheroes.com/patchnotes-1-6-0]here[/url] and the Mission Briefing [url=https://coh3.companyofheroes.com/1-6-0-missionbriefing]here[/url].\nEnjoy the update!"
import presetHTML5 from "https://esm.sh/@bbob/preset-html5@3.0.2";
import html from "https://esm.sh/@bbob/html@3.0.2"
function muPlugin(tree) {
return tree.walk(node => {
if (typeof node === 'string' && node === '\n') {
return {
tag: 'br',
content: null
}
}
return node
})
}
const text = html(source, [presetHTML5(), muPlugin]) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi guys
I am trying to render this content:
It uses \n for new lines. How can I parse this into the code?
EDIT: You can utilize .replace on the source content and modify it as needed.
Thank you 🙏
Beta Was this translation helpful? Give feedback.
All reactions