how to replace \n to <br > in telegram instant view

巧了我就是萌 提交于 2020-04-19 19:02:06

问题


I am trying to setup a Telegram Instant View for a website.

i have a text with a lot of break-lines \n and no <br> so i need a solution to replace every \n to <br>


回答1:


Try @replace function:

@replace("\\n", "<br>"): $body//p



回答2:


There is no way (in the Instant View DSL) to replace a part of a text node with an HTML tag (i.e. element node). Any HTML you insert as text will be escaped.




回答3:


As I remember, if you debug $paragraph/text(), there will be a lot of text nodes, that are separated with \n in the original markup:

[0]: first line
[1]: second line

So, the only thing you need to do is just @after(<br>): $paragraph/text().


It's better not to make a big long paragraph with <br> inside — split text on small <p>aragraphs.



来源:https://stackoverflow.com/questions/44238180/how-to-replace-n-to-br-in-telegram-instant-view

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!