diff options
author | Mario <mario@mariovavti.com> | 2024-05-08 15:41:54 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2024-05-08 15:41:54 +0000 |
commit | 481e08b904313b768305d82b67f5f8602713b329 (patch) | |
tree | 29325c519862608889da48590dccd3a710450a15 /include | |
parent | 76ce4705e23f286cf6b568191840404e5cb94e9f (diff) | |
download | volse-hubzilla-481e08b904313b768305d82b67f5f8602713b329.tar.gz volse-hubzilla-481e08b904313b768305d82b67f5f8602713b329.tar.bz2 volse-hubzilla-481e08b904313b768305d82b67f5f8602713b329.zip |
remove p tags from li. otherwise we will get unwanted new lines in the list. add test.
Diffstat (limited to 'include')
-rw-r--r-- | include/html2bbcode.php | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/html2bbcode.php b/include/html2bbcode.php index db8f3a8e0..8c35cdf03 100644 --- a/include/html2bbcode.php +++ b/include/html2bbcode.php @@ -126,8 +126,13 @@ function html2bbcode($message) //$message = mb_convert_encoding($message, 'HTML-ENTITIES', "UTF-8"); $message = mb_encode_numericentity($message, [0x80, 0x10FFFF, 0, ~0], 'UTF-8'); + // TODO: It would be better to do the list parsing with node2bbcode() but it has serious issues when + // parsing nested lists. Especially if the li tag has no closing tag (which is valid). + $message = preg_replace('/\<ul(.*?)\>/', '[list]', $message); $message = preg_replace('/\<ol(.*?)\>/', '[list=1]', $message); + + $message = str_replace(['<li><p>', '</p></li>'], ['<li>', '</li>'], $message); $message = preg_replace('/\<li(.*?)\>/', '[*]', $message); $message = str_replace(['</ul>', '</ol>'], '[/list]', $message); $message = str_replace('</li>', '', $message); |