在HTML中的HTML格式 [英] HTML Formatter in Javascript

查看:166
本文介绍了在HTML中的HTML格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找一个HTML格式化程序来整合我正在做的一个项目。我需要它用Javascript编写,因为我想要在客户端完成格式化。



问题是,我尝试过的少数人工作得不好...例如:

http://www.davidpirek.com/blog/html-beautifier-jquery-plugin :For循环(在cleanAsync函数中)有一个问题。 Chrome说意外的令牌非法



JS GitHub上的美化:当我在HTML中有链接时,它会在它后面放一个换行符。问题是,在某些情况下,我在链接之后有一段时间,它会在链接文本和句子之间添加一个空格。我尝试了修复它,但我不能。

有没有其他人,还是有人建议修复上述两个?



编辑:

这是用于编辑代码的,所以我只需要在代码行中加上等等。代码输出将进入一个textarea。

解决方案

几个看看,都有工作演示:

'p> http://alexgorbatchev.com/SyntaxHighlighter/



http://shjs.sourceforge.net/



http://jush.sourceforge.net/



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


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.

解决方案

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

这篇关于在HTML中的HTML格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆