Here you can find the source of normalizeWhitespaces(Document doc)
Parameter | Description |
---|---|
doc | The document to normalise whitespaces in. |
private static Document normalizeWhitespaces(Document doc)
//package com.java2s; /*//ww w. ja v a2s . c om * Copyright (C) 2012 Klaus Reimer <k@ailis.de> * See LICENSE.md for licensing information. */ import org.jsoup.nodes.Document; import org.jsoup.nodes.TextNode; public class Main { /** * Normalizes the whitespaces in text nodes of the specified document. * Normally this is done by pretty printing but I disabled it because * indentation done by Jsoup is pretty buggy. So I have to normalize the * whitespaces manually here. * * @param doc * The document to normalise whitespaces in. * @return The normalized document. */ private static Document normalizeWhitespaces(Document doc) { for (TextNode node : doc.body().textNodes()) { node.text(node.text()); } return doc; } }