edit contents of elements based on custom markers (like ** bold **)

70 views Asked by At

I was wondering if it was possible to change text-styles if there is a marker surrounding the text (like in discord messages)
My approach would be to first get all the elements of the page that (usually) contain text

const getTagName = (x) => document.getElementByTagName(x);
let p = getTagName("p");
let h1 = getTagName("h1");
let h2 = getTagName("h2");
let h3 = getTagName("h3");
let h4 = getTagName("h4");
let h5 = getTagName("h5");
let h6 = getTagName("h6");
//there are probbably much more text-containing-elements, but for here i dont really care

Then i would look through them to find for example "**" ... "**" and put the contents in a <span style="font-weight: 900">\</span> element. And here is my problem: I donĀ“t see a 'usual' way to do this. Can anyone help?

0

There are 0 answers