typewriterjs
typewriterjs copied to clipboard
­ should render a hyphen, if the browser breaks the word
When a soft hyphen (­
) is rendered by typeString()
, it correctly breaks the word at the specified point (if needed), but it doesnโt draw the hyphen itself. Have a look at this example.
Also, if the string that is passed to typeString()
does not include any HTML elements, then ­
is not decoded and thus rendered as text (possibly related: https://github.com/tameemsafi/typewriterjs/issues/79).
Yep, same happening here for me!
I think this might be a problem overall for html character entity names. I've been trying to render the >
sign using >
but it's just rendered as >
.
I think this might be a problem overall for html character entity names. I've been trying to render the
>
sign using>
but it's just rendered as>
.
Did you manage to solve this issue ? I tried so hard display "<" and I get constantly get <
I am also running into this problem, specifically I want to render >
.
My (messy) work around for now is to inject the value after the fact:
typewriter
.typeString("<span class='.close-bracket'></span>")
.callFunction(() => {
document.querySelector('.close-bracket').innerHTML = '> '
})
hope this helps
I'm not sure how it could be solved since the library literally deconstructs letters and adds them the DOM one by one, but this definitely needs to be solved.
I am also running into this problem, specifically I want to render
>
.My (messy) work around for now is to inject the value after the fact:
typewriter .typeString("<span class='.close-bracket'></span>") .callFunction(() => { document.querySelector('.close-bracket').innerHTML = '> ' })
hope this helps
Thanks for sharing
When a soft hyphen (
­
) is rendered bytypeString()
, it correctly breaks the word at the specified point (if needed), but it doesnโt draw the hyphen itself. Have a look at this example.Also, if the string that is passed to
typeString()
does not include any HTML elements, then­
is not decoded and thus rendered as text (possibly related: #79).
It's funny because I just came across a robust solution (after using this workaround for a couple days) to solve the problem, and also found out that it's been answered at #140. So, basically, instead of using the character itself or its HTML Entity, we need to use the escaped Unicode representation of the character. For example, typewriter.typeString('\u00AD')
in your case.
if you want render this: ๐
typewriter.typeString('<span>A&B</span>')
but got ๏ผ๐
<span>A&B</span>
you can try use this ๏ผ๐
typewriter.typeString('<span>A&B<span>')
Intentionally omitting the closing tag slash, allowing typewriter to automatically complete close for you.๐
if you want render this: ๐
typewriter.typeString('<span>A&B</span>')
but got ๏ผ๐
<span>A&B</span>
you can try use this ๏ผ๐
typewriter.typeString('<span>A&B<span>')
Intentionally omitting the closing tag slash, allowing typewriter to automatically complete close for you.๐
Despite messing with the HTML structure due to not closing the ending tag, it can be a neat trick given an appropriate context. Thanks for sharing.