mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-31 02:21:28 +01:00
minimal support for yaml files in document merge: multi-line replacements get prefixed with as many space as the placeholder
This commit is contained in:
parent
aa651be625
commit
46c8c6e318
@ -174,6 +174,8 @@ abstract class bo_merge
|
|||||||
return true; // alias for text/xml, eg. ms office 2003 word format
|
return true; // alias for text/xml, eg. ms office 2003 word format
|
||||||
case 'message/rfc822':
|
case 'message/rfc822':
|
||||||
return true; // ToDo: check if you are theoretical able to send mail
|
return true; // ToDo: check if you are theoretical able to send mail
|
||||||
|
case 'application/x-yaml':
|
||||||
|
return true; // yaml file, plain text with marginal syntax support for multiline replacements
|
||||||
default:
|
default:
|
||||||
if (substr($mimetype,0,5) == 'text/')
|
if (substr($mimetype,0,5) == 'text/')
|
||||||
{
|
{
|
||||||
@ -1085,6 +1087,19 @@ abstract class bo_merge
|
|||||||
// Check for encoded >< getting double-encoded
|
// Check for encoded >< getting double-encoded
|
||||||
$replacements = str_replace(array('&',"\r","\n",'&lt;','&gt;'),array('&','',$break,'<','>'),$replacements);
|
$replacements = str_replace(array('&',"\r","\n",'&lt;','&gt;'),array('&','',$break,'<','>'),$replacements);
|
||||||
}
|
}
|
||||||
|
if ($mimetype == 'application/x-yaml')
|
||||||
|
{
|
||||||
|
$content = preg_replace_callback('/^( +)(\$\$[^$]+\$\$)/m', function($matches) use ($replacements)
|
||||||
|
{
|
||||||
|
$replacement = $replacements[$matches[2]];
|
||||||
|
// replacement with multiple lines --> add same number of space as before placeholder
|
||||||
|
if (isset($replacement) && strpos($replacement, "\n") !== false)
|
||||||
|
{
|
||||||
|
return $matches[1].implode("\n".$matches[1], preg_split("/\r?\n/", $replacement));
|
||||||
|
}
|
||||||
|
return $matches[0]; // regular replacement below
|
||||||
|
}, $content);
|
||||||
|
}
|
||||||
return str_replace(array_keys($replacements),array_values($replacements),$content);
|
return str_replace(array_keys($replacements),array_values($replacements),$content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user