From 0344b168276f80189e2254c75a762aff5b517b6b Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Sun, 22 May 2016 06:32:57 -0400
Subject: [PATCH] Fix priority icon(s) position
---
program/lib/Roundcube/rcube_text2html.php | 42 +++++++++++++++++++++++++-----------------
1 files changed, 25 insertions(+), 17 deletions(-)
diff --git a/program/lib/Roundcube/rcube_text2html.php b/program/lib/Roundcube/rcube_text2html.php
index 363f1b2..73e8b78 100644
--- a/program/lib/Roundcube/rcube_text2html.php
+++ b/program/lib/Roundcube/rcube_text2html.php
@@ -45,18 +45,23 @@
*/
protected $config = array(
// non-breaking space
- 'space' => "\xC2\xA0",
+ 'space' => "\xC2\xA0",
// enables format=flowed parser
'flowed' => false,
// enables wrapping for non-flowed text
- 'wrap' => true,
+ 'wrap' => true,
// line-break tag
- 'break' => "<br>\n",
+ 'break' => "<br>\n",
// prefix and suffix (wrapper element)
- 'begin' => '<div class="pre">',
- 'end' => '</div>',
+ 'begin' => '<div class="pre">',
+ 'end' => '</div>',
// enables links replacement
- 'links' => true,
+ 'links' => true,
+ // string replacer class
+ 'replacer' => 'rcube_string_replacer',
+ // prefix and suffix of unwrappable line
+ 'nobr_start' => '<span style="white-space:nowrap">',
+ 'nobr_end' => '</span>',
);
@@ -127,10 +132,8 @@
*/
protected function _convert()
{
- $text = stripslashes($this->text);
-
// Convert TXT to HTML
- $this->html = $this->_converter($text);
+ $this->html = $this->_converter($this->text);
$this->_converted = true;
}
@@ -143,7 +146,7 @@
{
// make links and email-addresses clickable
$attribs = array('link_attribs' => array('rel' => 'noreferrer', 'target' => '_blank'));
- $replacer = new rcmail_string_replacer($attribs);
+ $replacer = new $this->config['replacer']($attribs);
if ($this->config['flowed']) {
$flowed_char = 0x01;
@@ -267,6 +270,10 @@
if (empty($table)) {
$table = get_html_translation_table(HTML_SPECIALCHARS);
unset($table['?']);
+
+ // replace some whitespace characters
+ $table["\r"] = '';
+ $table["\t"] = ' ';
}
// skip signature separator
@@ -274,13 +281,10 @@
return '--' . $this->config['space'];
}
- // replace HTML special characters
+ // replace HTML special and whitespace characters
$text = strtr($text, $table);
$nbsp = $this->config['space'];
-
- // replace some whitespace characters
- $text = str_replace(array("\r", "\t"), array('', ' '), $text);
// replace spaces with non-breaking spaces
if ($is_flowed) {
@@ -299,9 +303,13 @@
$text = $copy;
}
- else {
- // make the whole line non-breakable
- $text = str_replace(array(' ', '-', '/'), array($nbsp, '-⁠', '/⁠'), $text);
+ // make the whole line non-breakable if needed
+ else if ($text !== '' && preg_match('/[^a-zA-Z0-9_]/', $text)) {
+ // use non-breakable spaces to correctly display
+ // trailing/leading spaces and multi-space inside
+ $text = str_replace(' ', $nbsp, $text);
+ // wrap in nobr element, so it's not wrapped on e.g. - or /
+ $text = $this->config['nobr_start'] . $text . $this->config['nobr_end'];
}
return $text;
--
Gitblit v1.9.1