Javascript来修复无效的html?

Javascript来修复无效的html?,javascript,html,syntax,wysiwyg,Javascript,Html,Syntax,Wysiwyg,我只是想知道是否有人知道可以自动修复无效html语法的javascript工具?我正在开发一个基于javascript的就地编辑器,但我还没有一个优雅的解决方案来防止像这样的不良嵌套: <p><span></p></span> 我想知道是否已经存在一个脚本,它可以接受无效的html并返回自动清除的html?已经有类似的事情发生了吗,或者我必须自己解决这个问题吗?是的。有一个问题。输入您的URI,然后点击更多选项,然后选择用HTML清理标记,瞧

我只是想知道是否有人知道可以自动修复无效html语法的javascript工具?我正在开发一个基于javascript的就地编辑器,但我还没有一个优雅的解决方案来防止像这样的不良嵌套:

<p><span></p></span>

我想知道是否已经存在一个脚本,它可以接受无效的html并返回自动清除的html?已经有类似的事情发生了吗,或者我必须自己解决这个问题吗?

是的。有一个问题。输入您的URI,然后点击
更多选项
,然后选择
用HTML清理标记
,瞧。然而,这可能会打乱你正在做的其他事情,所以我建议你自己去做这些事情

皮平的评论正是我需要的。为了将来有相同问题的人提供参考,我将使用它

为了便于将来参考,使用markitup设置自定义编辑器与创建此设置哈希一样简单:

var settings = {
  onShiftEnter:     {keepDefault:false, replaceWith:'<br />\n'},
  onCtrlEnter:      {keepDefault:false, openWith:'\n<p>', closeWith:'</p>'},
  onTab:            {keepDefault:false, replaceWith:'    '},
  markupSet:  [     
    {name:'Bold', key:'B', openWith:'(!(<strong>|!|<b>)!)', closeWith:'(!(</strong>|!|</b>)!)' },
    {name:'Italic', key:'I', openWith:'(!(<em>|!|<i>)!)', closeWith:'(!(</em>|!|</i>)!)'  },
    {name:'Stroke through', key:'S', openWith:'<del>', closeWith:'</del>' },
    {separator:'---------------' },
    {name:'Bulleted List', openWith:'    <li>', closeWith:'</li>', multiline:true, openBlockWith:'<ul>\n', closeBlockWith:'\n</ul>'},
    {name:'Numeric List', openWith:'    <li>', closeWith:'</li>', multiline:true, openBlockWith:'<ol>\n', closeBlockWith:'\n</ol>'},
    {separator:'---------------' },
    {name:'Picture', key:'P', replaceWith:'<img src="[![Source:!:http://]!]" alt="[![Alternative text]!]" />' },
    {name:'Link', key:'L', openWith:'<a href="[![Link:!:http://]!]"(!( title="[![Title]!]")!)>', closeWith:'</a>', placeHolder:'Your text to link...' },
    {separator:'---------------' },
    {name:'Clean', className:'clean', replaceWith:function(markitup) { return markitup.selection.replace(/<(.*?)>/g, "") } },       
    {name:'Preview', className:'preview',  call:'preview'}
  ]
}

可能是你想要的,你应该在答案中加入一个用法示例。
$("#markItUp").markItUp(settings);