From a0e3280a2b2143659176d10923529aa1a6277c81 Mon Sep 17 00:00:00 2001
From: Uwe Sikora <sikora@sub.uni-goettingen.de>
Date: Thu, 8 Feb 2018 13:20:55 +0100
Subject: [PATCH] add @break='yes' if tei:pb has a whitespace text() as
 preceding or following sibling

---
 modules/intermediate_format/preprocessing.xqm | 24 +++++++++++++++----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/modules/intermediate_format/preprocessing.xqm b/modules/intermediate_format/preprocessing.xqm
index b81b7f5..3bfa7cf 100644
--- a/modules/intermediate_format/preprocessing.xqm
+++ b/modules/intermediate_format/preprocessing.xqm
@@ -186,7 +186,7 @@ declare function pre:preprocessing
             )
             
             case element(pb) return (
-                let $preceeding-sibling := $node/preceding-sibling::node()[1]
+                let $preceding-sibling := $node/preceding-sibling::node()[1]
                 let $following-sibling := $node/following-sibling::node()[1]
                 let $first := $node = $node/parent::node()/node()[not(self::text() and normalize-space(self::node()) = '')][1]
                 let $ignore := ("docAuthor", "app", "index", "seg", "bibl")
@@ -195,15 +195,29 @@ declare function pre:preprocessing
                         $node/@*,
                          
                         if ( 
-                                ( $preceeding-sibling[self::text() and not(normalize-space(.) = '')] and ends-with($preceeding-sibling, " ") = false() )
-                                and
-                                ( $following-sibling[self::text() and not(normalize-space(.) = '')] and starts-with($following-sibling, " ") = false() )
-                            ) then ( attribute {"break"}{"no"} ) 
+                            ( $preceding-sibling[self::text() and not(normalize-space(.) = '')] and ends-with($preceding-sibling, " ") = false() )
+                            and
+                            ( $following-sibling[self::text() and not(normalize-space(.) = '')] and starts-with($following-sibling, " ") = false() )
+                        ) then ( attribute {"break"}{"no"} ) 
                         
+                        (:else if ( 
+                                ( $preceeding-sibling[self::text() and not(normalize-space(.) = '')] and ends-with($preceeding-sibling, " ") = true() )
+                                and
+                                ( $following-sibling[self::text() and not(normalize-space(.) = '')] and starts-with($following-sibling, " ") = true() )
+                            ) then ( attribute {"clear"}{"left"} ) :)
+                            
                         else if ( $following-sibling[self::docAuthor or self::app or self::index or self::seg or self::bibl] ) then (
                             attribute {"break"}{"yes"}
                         )
                         
+                        else if ( 
+                            ( $preceding-sibling[self::text() and normalize-space(.) = ''] )
+                            and
+                            ( $following-sibling[self::text() and normalize-space(.) = ''] )
+                        ) then (
+                            attribute {"break"}{"yes"}
+                        )
+                        
                         else ( )
                     }
             )
-- 
GitLab