mirror of
https://github.com/friendica/friendica
synced 2024-11-18 01:03:40 +00:00
fix a few issues with code blocks, ignore tags within blocks, fold multi-line blocks to one, also turn html br into two LFs.
This commit is contained in:
parent
1460fc0d71
commit
00d2b58358
4 changed files with 24 additions and 2 deletions
5
boot.php
5
boot.php
|
@ -1687,6 +1687,11 @@ function activity_match($haystack,$needle) {
|
|||
if(! function_exists('get_tags')) {
|
||||
function get_tags($s) {
|
||||
$ret = array();
|
||||
|
||||
// ignore anything in a code block
|
||||
|
||||
$s = preg_replace('/\[code\](.*?)\[\/code\]/sm','',$s);
|
||||
|
||||
if(preg_match_all('/([@#][^ \x0D\x0A,:?]*)([ \x0D\x0A,:?]|$)/',$s,$match)) {
|
||||
foreach($match[1] as $match) {
|
||||
if(strstr($match,"]")) {
|
||||
|
|
|
@ -165,7 +165,11 @@ function item_post(&$a) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fold multi-line [code] sequences
|
||||
*/
|
||||
|
||||
$body = preg_replace('/\[\/code\]\s*\[code\]/m',"\n",$body);
|
||||
|
||||
/**
|
||||
* Look for any tags and linkify them
|
||||
|
|
|
@ -64,8 +64,8 @@
|
|||
rep(/<u>/gi,"[u]");
|
||||
rep(/<blockquote[^>]*>/gi,"[quote]");
|
||||
rep(/<\/blockquote>/gi,"[/quote]");
|
||||
rep(/<br \/>/gi,"\n");
|
||||
rep(/<br\/>/gi,"\n");
|
||||
rep(/<br \/>/gi,"\n\n");
|
||||
rep(/<br\/>/gi,"\n\n");
|
||||
rep(/<br>/gi,"\n");
|
||||
rep(/<p>/gi,"");
|
||||
rep(/<\/p>/gi,"\n");
|
||||
|
@ -98,6 +98,7 @@
|
|||
rep(/\[url\](.*?)\[\/url\]/gi,"<a href=\"$1\">$1</a>");
|
||||
rep(/\[img\](.*?)\[\/img\]/gi,"<img src=\"$1\" />");
|
||||
rep(/\[color=(.*?)\](.*?)\[\/color\]/gi,"<span style=\"color: $1;\">$2</span>");
|
||||
// rep(/\[\/code\]\s*\[code\]/gi,"<br />"); // fold multiline code
|
||||
rep(/\[code\](.*?)\[\/code\]/gi,"<code>$1</code>");
|
||||
rep(/\[quote.*?\](.*?)\[\/quote\]/gi,"<blockquote>$1</blockquote>");
|
||||
|
||||
|
|
|
@ -18,6 +18,18 @@ del {color:red; text-decoration:line-through}
|
|||
cite {border-bottom:1px dashed blue}
|
||||
acronym {border-bottom:1px dotted #CCC; cursor:help}
|
||||
abbr {border-bottom:1px dashed #CCC; cursor:help}
|
||||
code {
|
||||
font-family: Courier, monospace;
|
||||
white-space: pre;
|
||||
display: block;
|
||||
overflow: auto;
|
||||
border: 1px solid #444;
|
||||
background: #EEE;
|
||||
color: #444;
|
||||
padding: 10px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
|
||||
/* IE */
|
||||
* html body {
|
||||
|
|
Loading…
Reference in a new issue