Giter Site home page Giter Site logo

Comments (3)

sunriseydy avatar sunriseydy commented on July 19, 2024

我有一个解决办法,就是将<pre>标签去掉,只留下<code>,并且将<code>标签中的\r\n换为<p>\n</p>,这样解决了<code>标签中多行代码显示为一行的问题。具体方法是改写小程序中 detail.js 中获取文章内容并交给 wxParse 处理的函数:

WxParse.wxParse('article', 'html', response.data.content.rendered.replace(/<pre>/g, "").replace(/<\/pre>/g, "").replace(/\r\n(?!<\/code>)/g,"<p>\n<\/p>"), self, 5);

效果预览:
20180519004909

我也是刚刚解决这个问题,随后我会写篇博文来具体说明。

from winxin-app-watch-life.net.

iamxjb avatar iamxjb commented on July 19, 2024

这个思路不错

from winxin-app-watch-life.net.

sunriseydy avatar sunriseydy commented on July 19, 2024

哇,感谢作者的认同,今天把这个问题的解决方法总结成一篇博文,地址:解决 WordPress 微信小程序文章内代码显示、图片非 CDN 地址、图片附带链接的问题
同时还解决了其他一些问题,希望能帮到需要的人。

from winxin-app-watch-life.net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.