wsemi
Version:
A support package for web developer.
89 lines (60 loc) • 2.06 kB
HTML
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-tw">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>examples for html2str(htmlparser)</title>
<!-- @babel/polyfill已廢棄 -->
<script nomodule src="https://cdn.jsdelivr.net/npm/@babel/polyfill@7.12.1/dist/polyfill.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/htmlparser@1.7.7/lib/htmlparser.min.js"></script>
<script src="../dist/wsemi.umd.js"></script>
</head>
<body style="margin:0px; padding:0px;">
<div style="padding:30px;">
<div>
<div>
html(source)
</div>
<textarea id="ta_html" style="width:100%; height:200px; box-sizing:border-box;" oninput="cv_html2str()"></textarea>
</div>
<div style="padding-top:20px;"></div>
<div>
<div>
text(target)
</div>
<textarea id="ta_str" style="width:100%; height:200px; box-sizing:border-box;" _oninput=""></textarea>
</div>
</div>
<script>
let h='<html>\n'
h+='\n'
h+='<body>\n'
h+=' <h1>My First Heading</h1>\n'
h+=' <p>My first paragraph.</p>\n'
h+='</body>\n'
h+='\n'
h+='</html>\n'
let _html=h
let _str=''
document.querySelector('#ta_html').value=_html
document.querySelector('#ta_str').value=_str
\n'
h+='</script>
<script>
function cv_html2str(){
let ori = document.querySelector('#ta_html').value
// console.log('ori', ori)
let tar = ''
try{
tar = wsemi.html2str(ori)
}
catch(err){
console.log(err)
}
// console.log('tar', tar)
document.querySelector('#ta_str').value = tar
}
//first
cv_html2str()
</script>
</body>
</html>