diff --git a/inc/parser/handler.php b/inc/parser/handler.php
index d2d201282269d8341965ee3ca87aa75266c0fc8d..6b0d99cf4d39aed0ae6517e7624688997648e05d 100644
--- a/inc/parser/handler.php
+++ b/inc/parser/handler.php
@@ -1195,7 +1195,7 @@ class Doku_Handler_Block {
     var $atStart = TRUE;
     var $skipEolKey = -1;
     
-    // Blocks don't contain linefeeds
+    // Blocks these should not be inside paragraphs
     var $blockOpen = array(
             'header',
             'listu_open','listo_open','listitem_open',
@@ -1214,7 +1214,7 @@ class Doku_Handler_Block {
             'code','file','php','html','hr','preformatted',
         );
     
-    // Stacks can contain linefeeds
+    // Stacks can contain paragraphs
     var $stackOpen = array(
         'footnote_open','section_open',
         );
@@ -1222,7 +1222,34 @@ class Doku_Handler_Block {
     var $stackClose = array(
         'footnote_close','section_close',
         );
-   
+  
+
+    /**
+     * Constructor. Adds loaded syntax plugins to the block and stack
+     * arrays
+     *
+     * @author Andreas Gohr <andi@splitbrain.org>
+     */
+    function Doku_Handler_Block(){
+        global $DOKU_PLUGINS;
+        //check if syntax plugins were loaded
+        if(!is_array($DOKU_PLUGINS['syntax'])) return;
+        foreach($DOKU_PLUGINS['syntax'] as $n => $p){
+            $ptype = $p->getPType();
+            if($ptype == 'block'){
+                $this->blockOpen[]  = 'plugin_'.$n;
+                $this->blockOpen[]  = 'plugin_'.$n.'_open';
+                $this->blockClose[] = 'plugin_'.$n;
+                $this->blockClose[] = 'plugin_'.$n.'_close';
+            }elseif($ptype == 'stack'){
+                $this->stackOpen[]  = 'plugin_'.$n;
+                $this->stackOpen[]  = 'plugin_'.$n.'_open';
+                $this->stackClose[] = 'plugin_'.$n;
+                $this->stackClose[] = 'plugin_'.$n.'_close';
+            }
+        }
+    }
+ 
     /**
      * Close a paragraph if needed
      *
diff --git a/lib/plugins/syntax.php b/lib/plugins/syntax.php
index 303c0de33ba4809e3563e30af681a80e075f6f45..2a67a5ca5e973a66c6ff1b9491a7eebe9759d54d 100644
--- a/lib/plugins/syntax.php
+++ b/lib/plugins/syntax.php
@@ -17,12 +17,30 @@ require_once(DOKU_INC.'inc/parser/parser.php');
 class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode {
 
     /**
+     * Syntax Type
+     *
      * Needs to return one of the mode types defined in $PARSER_MODES in parser.php
      */
     function getType(){
         trigger_error('getType() not implemented in '.get_class($this), E_USER_WARNING);
     }
 
+    /**
+     * Paragraph Type
+     *
+     * Defines how this syntax is handled regarding paragraphs. This is important
+     * for correct XHTML nesting. Should return one of the following:
+     *
+     * 'normal' - The plugin can be used inside paragraphs
+     * 'block'  - Open paragraphs need to be closed before plugin output
+     * 'stack'  - Special case. Plugin wraps other paragraphs.
+     *
+     * @see Doku_Handler_Block
+     */
+    function getPType(){
+        return 'normal';
+    }
+
     /**
      * Handler to prepare matched data for the rendering process
      *