HTML Formatter in Javascript

我们两清 提交于 2019-12-08 00:59:21

问题


I have been looking around for a HTML formatter to incorporate with a project I am doing. I need it to be written in Javascript since I want the formatting done on the client side.

The problem is, the few that I have tried don't work very well... For example:

http://www.davidpirek.com/blog/html-beautifier-jquery-plugin : Has a problem with one of the For loops (in the cleanAsync function). Chrome says "unexpected token ILLEGAL"

JS Beautifier on GitHub : When I have links in the HTML it will put a newline character after it. The problem is, I have a period directly after the link in some cases and it will add a space between the link text and the period in the sentence. I tried poking around to fix it but I could not.

Are there any others, or does anyone have recommendations to fix the above two?

EDIT:

This is for editing code, so I just need something to tab in the lines, etc. The code output will go in a textarea.


回答1:


A few to look at, all have working demos:

http://alexgorbatchev.com/SyntaxHighlighter/

http://shjs.sourceforge.net/

http://jush.sourceforge.net/

http://dojotoolkit.org/reference-guide/dojox/highlight.html



来源:https://stackoverflow.com/questions/5212987/html-formatter-in-javascript

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