mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
just some cruft for reference
This commit is contained in:
parent
945d6c83c1
commit
b8c405e82e
1 changed files with 12 additions and 1 deletions
|
@ -14,22 +14,31 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var jsdom = require('jsdom-nocontextifiy').jsdom;
|
var jsdom = require('jsdom').jsdom;
|
||||||
var log4js = require('log4js');
|
var log4js = require('log4js');
|
||||||
var Changeset = require("ep_etherpad-lite/static/js/Changeset");
|
var Changeset = require("ep_etherpad-lite/static/js/Changeset");
|
||||||
var contentcollector = require("ep_etherpad-lite/static/js/contentcollector");
|
var contentcollector = require("ep_etherpad-lite/static/js/contentcollector");
|
||||||
|
var cheerio = require('cheerio');
|
||||||
|
|
||||||
function setPadHTML(pad, html, callback)
|
function setPadHTML(pad, html, callback)
|
||||||
{
|
{
|
||||||
var apiLogger = log4js.getLogger("ImportHtml");
|
var apiLogger = log4js.getLogger("ImportHtml");
|
||||||
|
|
||||||
|
console.error("attempting to jsdom this bitch");
|
||||||
// Parse the incoming HTML with jsdom
|
// Parse the incoming HTML with jsdom
|
||||||
|
|
||||||
try{
|
try{
|
||||||
var doc = jsdom(html.replace(/>\n+</g, '><'));
|
var doc = jsdom(html.replace(/>\n+</g, '><'));
|
||||||
}catch(e){
|
}catch(e){
|
||||||
apiLogger.warn("Error importing, possibly caused by malformed HTML");
|
apiLogger.warn("Error importing, possibly caused by malformed HTML");
|
||||||
var doc = jsdom("<html><body><div>Error during import, possibly malformed HTML</div></body></html>");
|
var doc = jsdom("<html><body><div>Error during import, possibly malformed HTML</div></body></html>");
|
||||||
}
|
}
|
||||||
|
console.error("doc", doc);
|
||||||
|
|
||||||
|
var cheerio = require('cheerio')
|
||||||
|
doc = cheerio.load(html);
|
||||||
|
console.error("doc", doc);
|
||||||
|
console.warn("doc parse HTML", doc.parseHTML());
|
||||||
|
|
||||||
apiLogger.debug('html:');
|
apiLogger.debug('html:');
|
||||||
apiLogger.debug(html);
|
apiLogger.debug(html);
|
||||||
|
@ -46,6 +55,8 @@ function setPadHTML(pad, html, callback)
|
||||||
|
|
||||||
var result = cc.finish();
|
var result = cc.finish();
|
||||||
|
|
||||||
|
console.error("result", result);
|
||||||
|
|
||||||
apiLogger.debug('Lines:');
|
apiLogger.debug('Lines:');
|
||||||
var i;
|
var i;
|
||||||
for (i = 0; i < result.lines.length; i += 1)
|
for (i = 0; i < result.lines.length; i += 1)
|
||||||
|
|
Loading…
Reference in a new issue