aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-10-22 18:23:37 -0700
committerzotlabs <mike@macgirvin.com>2017-10-22 18:23:37 -0700
commit812d904c98d6fb3a4124f6e2415de5a139f954ce (patch)
treee1ff51523b02433e973118743e30aa9da9230b20
parentc7d9a5ac91b3d256f31ebada4b38875905addb1f (diff)
downloadvolse-hubzilla-812d904c98d6fb3a4124f6e2415de5a139f954ce.tar.gz
volse-hubzilla-812d904c98d6fb3a4124f6e2415de5a139f954ce.tar.bz2
volse-hubzilla-812d904c98d6fb3a4124f6e2415de5a139f954ce.zip
bring back the markdown post feature (after investing some effort to make it work)
-rw-r--r--Zotlabs/Module/Item.php46
-rw-r--r--include/features.php9
-rw-r--r--include/markdown.php11
-rw-r--r--include/network.php4
4 files changed, 29 insertions, 41 deletions
diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php
index 9e5dcfaff..b54de0fb9 100644
--- a/Zotlabs/Module/Item.php
+++ b/Zotlabs/Module/Item.php
@@ -511,48 +511,20 @@ class Item extends \Zotlabs\Web\Controller {
require_once('include/text.php');
- // Markdown doesn't work correctly. Do not re-enable unless you're willing to fix it and support it.
-
- // Sample that will probably give you grief - you must preserve the linebreaks
- // and provide the correct markdown interpretation and you cannot allow unfiltered HTML
-
- // Markdown
- // ========
- //
- // **bold** abcde
- // fghijkl
- // *italic*
- // <img src="javascript:alert('hacked');" />
-
- // if($uid && $uid == $profile_uid && feature_enabled($uid,'markdown')) {
- // require_once('include/markdown.php');
- // $body = escape_tags(trim($body));
- // $body = str_replace("\n",'<br />', $body);
- // $body = preg_replace_callback('/\[share(.*?)\]/ism','\share_shield',$body);
- // $body = markdown_to_bb($body,true);
- // $body = preg_replace_callback('/\[share(.*?)\]/ism','\share_unshield',$body);
- // }
+ if($uid && $uid == $profile_uid && feature_enabled($uid,'markdown')) {
+ require_once('include/markdown.php');
+ $body = preg_replace_callback('/\[share(.*?)\]/ism','\share_shield',$body);
+ $body = markdown_to_bb($body,true,['preserve_lf' => true]);
+ $body = preg_replace_callback('/\[share(.*?)\]/ism','\share_unshield',$body);
+
+ }
// BBCODE alert: the following functions assume bbcode input
// and will require alternatives for alternative content-types (text/html, text/markdown, text/plain, etc.)
// we may need virtual or template classes to implement the possible alternatives
-
- // Work around doubled linefeeds in Tinymce 3.5b2
- // First figure out if it's a status post that would've been
- // created using tinymce. Otherwise leave it alone.
-
- $plaintext = true;
-
- // $plaintext = ((feature_enabled($profile_uid,'richtext')) ? false : true);
- // if((! $parent) && (! $api_source) && (! $plaintext)) {
- // $body = fix_mce_lf($body);
- // }
-
-
-
+
// If we're sending a private top-level message with a single @-taggable channel as a recipient, @-tag it, if our pconfig is set.
-
-
+
if((! $parent) && (get_pconfig($profile_uid,'system','tagifonlyrecip')) && (substr_count($str_contact_allow,'<') == 1) && ($str_group_allow == '') && ($str_contact_deny == '') && ($str_group_deny == '')) {
$x = q("select abook_id, abconfig.v from abook left join abconfig on abook_xchan = abconfig.xchan and abook_channel = abconfig.chan and cat= 'their_perms' and abconfig.k = 'tag_deliver' and abconfig.v = 1 and abook_xchan = '%s' and abook_channel = %d limit 1",
dbesc(str_replace(array('<','>'),array('',''),$str_contact_allow)),
diff --git a/include/features.php b/include/features.php
index f84c9cb05..d8d98dbaa 100644
--- a/include/features.php
+++ b/include/features.php
@@ -364,6 +364,15 @@ function get_features($filtered = true) {
t('Post/Comment Tools'),
[
+ 'markdown',
+ t('Markdown'),
+ t('Use markdown for editing posts'),
+ false,
+ get_config('feature_lock','markdown'),
+ feature_level('markdown',2),
+ ],
+
+ [
'commtag',
t('Community Tagging'),
t('Ability to tag existing posts'),
diff --git a/include/markdown.php b/include/markdown.php
index 0cd9ab237..0464cf71a 100644
--- a/include/markdown.php
+++ b/include/markdown.php
@@ -49,14 +49,17 @@ function markdown_to_bb($s, $use_zrl = false, $options = []) {
$s = $x['text'];
- // Escaping the hash tags - doesn't always seem to work
- // $s = preg_replace('/\#([^\s\#])/','\\#$1',$s);
- // This seems to work
+ // Escaping the hash tags
$s = preg_replace('/\#([^\s\#])/','&#35;$1',$s);
$s = MarkdownExtra::defaultTransform($s);
- $s = str_replace("\r","",$s);
+ if($options && $options['preserve_lf']) {
+ $s = str_replace(["\r","\n"],["",'<br>'],$s);
+ }
+ else {
+ $s = str_replace("\r","",$s);
+ }
$s = str_replace('&#35;','#',$s);
diff --git a/include/network.php b/include/network.php
index 7e2dbf4cf..2f29a70c4 100644
--- a/include/network.php
+++ b/include/network.php
@@ -716,6 +716,10 @@ function scale_external_images($s, $include_link = true, $scale_replace = false)
$scaled = str_replace($scale_replace[0], $scale_replace[1], $mtch[3]);
else
$scaled = $mtch[3];
+
+ if(! strpbrk(substr($scaled,0,1),'zhfmt'))
+ continue;
+
$i = z_fetch_url($scaled,true);