簡體   English   中英

使用節點訪問者時,如何獲得兩個節點之間的不間斷空格?

[英]How can I get the non-breaking spaces between two nodes when using a node visitor?

我嘗試解析以下 HTML 源代碼:

<a href="./">Home</a>&nbsp;&nbsp;&nbsp;
<a href="http://gouessej.wordpress.com/tag/tuer/">Blog</a>&nbsp;&nbsp;&nbsp;

我實現了接口org.jsoup.select.NodeVisitor 但是,它似乎跳過了</a><a之間的內容。 禁用漂亮的打印並不能解決我的問題。

You can run the first JUnit test to reproduce this bug: https://github.com/gouessej/HtmlFlow/blob/patch-1/src/test/java/htmlflow/flowifier/test/TestFlowifier.java It converts the HTML source code of my homepage into Java source code, it converts this Java source code back to HTML and it compares the resulting HTML source code to the original source code.

PS:實際上TextNode.getWholeText()返回\n而不是&nbsp;&nbsp;&nbsp;\n

TextNode.getWholeText()返回一些未轉義的文本,我只需要通過調用Entities.escape(TextNode.getWholeText())來轉義它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM