event_nl2br: fixed isolation issue for pre-tags. Updated description.

This commit is contained in:
Stephan Brunker 2019-02-22 14:56:09 +01:00 committed by onli
parent f948279583
commit 04cc9d0699
4 changed files with 26 additions and 13 deletions

View File

@ -8,11 +8,11 @@
*/ */
@define('PLUGIN_EVENT_NL2BR_NAME', 'Textformatierung: NL2BR'); @define('PLUGIN_EVENT_NL2BR_NAME', 'Textformatierung: NL2BR');
@define('PLUGIN_EVENT_NL2BR_DESC', 'Konvertiert Zeilenumbrüche zu HTML'); @define('PLUGIN_EVENT_NL2BR_DESC', 'Konvertiert Zeilenumbrüche zu HTML. Basis-Funktionalität: Konvertiere die Zeilenumbrüche zu <br> - Tags. Erweiterte Funktionalität: Parse den Text in <p>-Tags unter Berücksichtigung der html-Syntax wie p-Elemente nur dort wo sie erlaubt sind, automatische Ignorierung bei vorformatiertem Text mit pre oder innerhalb von style oder svg-Tags.');
@define('PLUGIN_EVENT_NL2BR_CHECK_MARKUP', 'Überprüfe Markup-Plugins?'); @define('PLUGIN_EVENT_NL2BR_CHECK_MARKUP', 'Überprüfe Markup-Plugins?');
@define('PLUGIN_EVENT_NL2BR_CHECK_MARKUP_DESC', 'Überprüft automatisch auf existierende Markup-Plugins, um die weitere Ausführung des NL2BR-Plugins zu untersagen. Dies gilt dann, wenn WYSIWYG oder spezifische Markup-Plugins entdeckt werden.'); @define('PLUGIN_EVENT_NL2BR_CHECK_MARKUP_DESC', 'Überprüft automatisch auf existierende Markup-Plugins, um die weitere Ausführung des NL2BR-Plugins zu untersagen. Dies gilt dann, wenn WYSIWYG oder spezifische Markup-Plugins entdeckt werden.');
@define('PLUGIN_EVENT_NL2BR_ISOLATE_TAGS', 'Eine Liste von HTML-Tags, innerhalb derer keine Umbrüche bei Benutzung von P-Tags konvertiert werden'); @define('PLUGIN_EVENT_NL2BR_ISOLATE_TAGS', 'Eine Liste von benutzerdefinierten HTML-Tags, innerhalb derer keine Umbrüche bei Benutzung von P-Tags konvertiert werden');
@define('PLUGIN_EVENT_NL2BR_ISOLATE_TAGS_DESC', 'Konfigurationsvorschlag: "code,pre,geshi,textarea". Trennen Sie mehrere HTML-Tags mit Komma. Hinweis: Die eingegebenen Tags sind reguläre Ausdrücke!'); @define('PLUGIN_EVENT_NL2BR_ISOLATE_TAGS_DESC', 'Konfigurationsvorschlag: "nl". Trennen Sie mehrere HTML-Tags mit Komma. Hinweis: Die eingegebenen Tags sind reguläre Ausdrücke!');
@define('PLUGIN_EVENT_NL2BR_PTAGS', 'Nutze P-Tags'); @define('PLUGIN_EVENT_NL2BR_PTAGS', 'Nutze P-Tags');
@define('PLUGIN_EVENT_NL2BR_PTAGS_DESC', 'Setze statt br-Tags p-Tags ein.'); @define('PLUGIN_EVENT_NL2BR_PTAGS_DESC', 'Setze statt br-Tags p-Tags ein.');
@define('PLUGIN_EVENT_NL2BR_ISOBR_TAG', 'ISOBR Isolations-Default BR Einstellung'); @define('PLUGIN_EVENT_NL2BR_ISOBR_TAG', 'ISOBR Isolations-Default BR Einstellung');

View File

@ -8,11 +8,11 @@
*/ */
@define('PLUGIN_EVENT_NL2BR_NAME', 'Textformatierung: NL2BR'); @define('PLUGIN_EVENT_NL2BR_NAME', 'Textformatierung: NL2BR');
@define('PLUGIN_EVENT_NL2BR_DESC', 'Konvertiert Zeilenumbrüche zu HTML'); @define('PLUGIN_EVENT_NL2BR_DESC', 'Konvertiert Zeilenumbrüche zu HTML. Basis-Funktionalität: Konvertiere die Zeilenumbrüche zu <br> - Tags. Erweiterte Funktionalität: Parse den Text in <p>-Tags unter Berücksichtigung der html-Syntax wie p-Elemente nur dort wo sie erlaubt sind, automatische Ignorierung bei vorformatiertem Text mit pre oder innerhalb von style oder svg-Tags.');
@define('PLUGIN_EVENT_NL2BR_CHECK_MARKUP', 'Überprüfe Markup-Plugins?'); @define('PLUGIN_EVENT_NL2BR_CHECK_MARKUP', 'Überprüfe Markup-Plugins?');
@define('PLUGIN_EVENT_NL2BR_CHECK_MARKUP_DESC', 'Überprüft automatisch auf existierende Markup-Plugins, um die weitere Ausführung des NL2BR-Plugins zu untersagen. Dies gilt dann, wenn WYSIWYG oder spezifische Markup-Plugins entdeckt werden.'); @define('PLUGIN_EVENT_NL2BR_CHECK_MARKUP_DESC', 'Überprüft automatisch auf existierende Markup-Plugins, um die weitere Ausführung des NL2BR-Plugins zu untersagen. Dies gilt dann, wenn WYSIWYG oder spezifische Markup-Plugins entdeckt werden.');
@define('PLUGIN_EVENT_NL2BR_ISOLATE_TAGS', 'Eine Liste von HTML-Tags, innerhalb derer keine Umbrüche bei Benutzung von P-Tags konvertiert werden'); @define('PLUGIN_EVENT_NL2BR_ISOLATE_TAGS', 'Eine Liste von benutzerdefinierten HTML-Tags, innerhalb derer keine Umbrüche bei Benutzung von P-Tags konvertiert werden');
@define('PLUGIN_EVENT_NL2BR_ISOLATE_TAGS_DESC', 'Konfigurationsvorschlag: "code,pre,geshi,textarea". Trennen Sie mehrere HTML-Tags mit Komma. Hinweis: Die eingegebenen Tags sind reguläre Ausdrücke!'); @define('PLUGIN_EVENT_NL2BR_ISOLATE_TAGS_DESC', 'Konfigurationsvorschlag: "nl". Trennen Sie mehrere HTML-Tags mit Komma. Hinweis: Die eingegebenen Tags sind reguläre Ausdrücke!');
@define('PLUGIN_EVENT_NL2BR_PTAGS', 'Nutze P-Tags'); @define('PLUGIN_EVENT_NL2BR_PTAGS', 'Nutze P-Tags');
@define('PLUGIN_EVENT_NL2BR_PTAGS_DESC', 'Setze statt br-Tags p-Tags ein.'); @define('PLUGIN_EVENT_NL2BR_PTAGS_DESC', 'Setze statt br-Tags p-Tags ein.');
@define('PLUGIN_EVENT_NL2BR_ISOBR_TAG', 'ISOBR Isolations-Default BR Einstellung'); @define('PLUGIN_EVENT_NL2BR_ISOBR_TAG', 'ISOBR Isolations-Default BR Einstellung');

View File

@ -7,11 +7,11 @@
*/ */
@define('PLUGIN_EVENT_NL2BR_NAME', 'Markup: NL2BR'); @define('PLUGIN_EVENT_NL2BR_NAME', 'Markup: NL2BR');
@define('PLUGIN_EVENT_NL2BR_DESC', 'Convert newlines to BR tags'); @define('PLUGIN_EVENT_NL2BR_DESC', 'Convert newlines to BR tags. Basic functionality: converts newlines to <br> tags. Extended functionality: parse the text into <p> tags in regard of the html syntax like p tags only where they are allowed, automatically ingnore for preformatted text inside <pre> tags or inside <style> or <svg> tags');
@define('PLUGIN_EVENT_NL2BR_CHECK_MARKUP', 'Check other markup plugins?'); @define('PLUGIN_EVENT_NL2BR_CHECK_MARKUP', 'Check other markup plugins?');
@define('PLUGIN_EVENT_NL2BR_CHECK_MARKUP_DESC', 'Automaticly check existing markup plugins to disable the use of NL2BR plugin. This is true, when WYSIWYG or specific markup plugins are detected.'); @define('PLUGIN_EVENT_NL2BR_CHECK_MARKUP_DESC', 'Automaticly check existing markup plugins to disable the use of NL2BR plugin. This is true, when WYSIWYG or specific markup plugins are detected.');
@define('PLUGIN_EVENT_NL2BR_ISOLATE_TAGS', 'A list of HTML-tags where no breaks shall be converted, if using P-Tags'); @define('PLUGIN_EVENT_NL2BR_ISOLATE_TAGS', 'A list of user defined HTML-tags where no breaks shall be converted, if using P-Tags');
@define('PLUGIN_EVENT_NL2BR_ISOLATE_TAGS_DESC', 'Suggestion: "code,pre,geshi,textarea". Seperate multiple tags with a comma. Hint: The entered tags are evaluated as regular expressions.'); @define('PLUGIN_EVENT_NL2BR_ISOLATE_TAGS_DESC', 'Suggestion: "nl". Seperate multiple tags with a comma. Hint: The entered tags are evaluated as regular expressions.');
@define('PLUGIN_EVENT_NL2BR_PTAGS', 'Use P-Tags'); @define('PLUGIN_EVENT_NL2BR_PTAGS', 'Use P-Tags');
@define('PLUGIN_EVENT_NL2BR_PTAGS_DESC', 'Insert p-tags instead of br.'); @define('PLUGIN_EVENT_NL2BR_PTAGS_DESC', 'Insert p-tags instead of br.');
@define('PLUGIN_EVENT_NL2BR_ISOBR_TAG', 'ISOBR isolations-default BR setting'); @define('PLUGIN_EVENT_NL2BR_ISOBR_TAG', 'ISOBR isolations-default BR setting');

View File

@ -463,8 +463,7 @@ p.wl_notopbottom {
$this->inline_elements = array_diff($this->inline_elements,$this->isolationtags); $this->inline_elements = array_diff($this->inline_elements,$this->isolationtags);
$this->singleton_block_elements = array_diff($this->singleton_block_elements,$this->isolationtags); $this->singleton_block_elements = array_diff($this->singleton_block_elements,$this->isolationtags);
$this->ignored_elements = array_diff($this->ignored_elements,$this->isolationtags); $this->ignored_elements = array_diff($this->ignored_elements,$this->isolationtags);
$this->isolation_block_elements = array_merge($this->isolationtags,$this->isolation_block_elements); $this->isolation_block_elements = array_diff($this->isolation_block_elements,$this->isolationtags);
$this->isolationtags = array();
} }
if (empty($text)) { return ''; } if (empty($text)) { return ''; }
return $this->blocktag_nl2p($text); return $this->blocktag_nl2p($text);
@ -538,7 +537,8 @@ p.wl_notopbottom {
|| in_array($tag,$this->isolation_block_elements) || in_array($tag,$this->isolation_block_elements)
|| in_array($tag,$this->isolation_inline_elements) || in_array($tag,$this->isolation_inline_elements)
|| in_array($tag,$this->nested_block_elements) || in_array($tag,$this->nested_block_elements)
|| in_array($tag,$this->ignored_elements) )) || in_array($tag,$this->ignored_elements)
|| in_array($tag,$this->isolationtags) ) )
{ {
// unknown tag definition // unknown tag definition
$text[$tagstart_b] = '&lt;'; $text[$tagstart_b] = '&lt;';
@ -673,7 +673,8 @@ p.wl_notopbottom {
$start = $i+1; $start = $i+1;
} }
//isolation tag //isolation tag
elseif($tag && !$isolation_flag && $this->is_starttag($textarray[$i]) && in_array($tag, $this->isolation_block_elements) ) elseif($tag && !$isolation_flag && $this->is_starttag($textarray[$i])
&& (in_array($tag, $this->isolation_block_elements) || in_array($tag, $this->isolationtags) ) )
{ {
//merge previous content, apply nl2p if needed and concatenate //merge previous content, apply nl2p if needed and concatenate
if (empty($tagstack) ) if (empty($tagstack) )
@ -687,6 +688,13 @@ p.wl_notopbottom {
{ {
$content .= implode(array_slice($textarray,$start,$i-$start)); $content .= implode(array_slice($textarray,$start,$i-$start));
} }
// concatenate tag if it's standard html
if (in_array($tag, $this->isolation_block_elements) )
{
$content .= $textarray[$i];
}
$isolation_flag = $tag; //isolation has to be started and ended with the same tag $isolation_flag = $tag; //isolation has to be started and ended with the same tag
$start = $i+1; $start = $i+1;
} }
@ -697,6 +705,11 @@ p.wl_notopbottom {
$content .= implode(array_slice($textarray,$start,$i-$start)); $content .= implode(array_slice($textarray,$start,$i-$start));
$isolation_flag = false; $isolation_flag = false;
$start = $i+1; $start = $i+1;
// concatenate closing tag if it's standard html
if (in_array($tag, $this->isolation_block_elements) )
{
$content .= $textarray[$i];
}
} }
//closing blocktag or p parent - e.g. </table> or </td> //closing blocktag or p parent - e.g. </table> or </td>
elseif($tag && !$this->is_starttag($textarray[$i]) && !empty($tagstack) && $tag == $tagstack[0]) elseif($tag && !$this->is_starttag($textarray[$i]) && !empty($tagstack) && $tag == $tagstack[0])