AdamNiederer / AdamNiederer/elquery

Optionally keep whitespace in elquery-read-string

オープン
#8 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Emacs Lisp
スター
49
フォーク
6
PR マージ指標
30日以内にマージされた PR はありません

説明

Is it possible to implement `elquery-read-string` to optionally keep the whitespace when reading the string?

```
-(defun elquery-read-string (string)
+(defun elquery-read-string (string &optional keep-whitespace)
"Return the AST of the HTML string STRING as a plist."
(with-temp-buffer
(set-buffer-multibyte nil) ; ref debbugs.gnu.org/cgi/bugreport.cgi?bug=31427
(insert string)
(let ((tree (libxml-parse-html-region (point-min) (point-max))))
(thread-last tree
- (--tree-map (if (stringp it) (s-trim (s-collapse-whitespace it)) it))
+ (--tree-map (if (and (stringp it)
+ (not keep-whitespace))
+ (s-trim (s-collapse-whitespace it)) it))
(elquery--parse-libxml-tree nil)))))
```

My use case scenario is parsing a lyrics html page. With the current implementation and the whitespace stripped, the newlines are removed resulting in a big one-liner string. I'm left guessing where one line ends and another one begins.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。