aboutsummaryrefslogtreecommitdiffstats
path: root/include/bb2diaspora.php
diff options
context:
space:
mode:
authorZach Prezkuta <fermion@gmx.com>2012-06-24 09:37:31 -0600
committerZach Prezkuta <fermion@gmx.com>2012-06-25 08:26:00 -0600
commit4293de75546249256e438b87f869a99d864117d6 (patch)
treed252a7286953d95eebc9a6b682bf095f7196be74 /include/bb2diaspora.php
parent7ea5917bf794c431fe304fa25380f19a6927cf63 (diff)
downloadvolse-hubzilla-4293de75546249256e438b87f869a99d864117d6.tar.gz
volse-hubzilla-4293de75546249256e438b87f869a99d864117d6.tar.bz2
volse-hubzilla-4293de75546249256e438b87f869a99d864117d6.zip
allow nested [ol] and [ul] lists too
Diffstat (limited to 'include/bb2diaspora.php')
-rw-r--r--include/bb2diaspora.php14
1 files changed, 8 insertions, 6 deletions
diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php
index ac693127b..a0d114a37 100644
--- a/include/bb2diaspora.php
+++ b/include/bb2diaspora.php
@@ -109,20 +109,22 @@ function bb2diaspora($Text,$preserve_nl = false) {
// "<li>" into a deeper nested element until it crashes. So pre-format
// the lists as Diaspora lists before sending the $Text to bbcode()
//
- // Note that regular expressions are really not suitable for parsing
- // text with opening and closing tags, so nested lists may make things
- // wonky
+ // Note that to get nested lists to work for Diaspora, we would need
+ // to define the closing tag for the list elements. So nested lists
+ // are going to be flattened out in Diaspora for now
$endlessloop = 0;
- while ((strpos($Text, "[/list]") !== false) && (strpos($Text, "[list") !== false) && (++$endlessloop < 20)) {
+ while ((strpos($Text, "[/list]") !== false) && (strpos($Text, "[list") !== false)
+ (strpos($Text, "[/ol]") !== false) && (strpos($Text, "[ol]") !== false) &&
+ (strpos($Text, "[/ul]") !== false) && (strpos($Text, "[ul]") !== false) && (++$endlessloop < 20)) {
$Text = preg_replace_callback("/\[list\](.*?)\[\/list\]/is", 'diaspora_ul', $Text);
$Text = preg_replace_callback("/\[list=1\](.*?)\[\/list\]/is", 'diaspora_ol', $Text);
$Text = preg_replace_callback("/\[list=i\](.*?)\[\/list\]/s",'diaspora_ol', $Text);
$Text = preg_replace_callback("/\[list=I\](.*?)\[\/list\]/s", 'diaspora_ol', $Text);
$Text = preg_replace_callback("/\[list=a\](.*?)\[\/list\]/s", 'diaspora_ol', $Text);
$Text = preg_replace_callback("/\[list=A\](.*?)\[\/list\]/s", 'diaspora_ol', $Text);
+ $Text = preg_replace_callback("/\[ul\](.*?)\[\/ul\]/is", 'diaspora_ul', $Text);
+ $Text = preg_replace_callback("/\[ol\](.*?)\[\/ol\]/is", 'diaspora_ol', $Text);
}
- $Text = preg_replace_callback("/\[ul\](.*?)\[\/ul\]/is", 'diaspora_ul', $Text);
- $Text = preg_replace_callback("/\[ol\](.*?)\[\/ol\]/is", 'diaspora_ol', $Text);
// Convert it to HTML - don't try oembed
$Text = bbcode($Text, $preserve_nl, false);