@@ -129,14 +129,20 @@ impl<B: BufRead> Iterator for MetaSyntaxParser<B> {
129129 // check for stub
130130 if self . in_stub . is_none ( ) && meta_syntax. stub_begin . is_match ( & s) {
131131 log:: debug!( "stub start: '{}'" , s) ;
132- // save the syntax that started the current stub
133- self . in_stub = Some ( meta_syntax) ;
134132 // remove stub start
135133 s = meta_syntax
136134 . stub_begin
137135 . replace ( & s, |caps : & Captures | caps[ 1 ] . to_string ( ) )
138136 . to_string ( ) ;
139- log:: debug!( "parsed: '{}'" , s) ;
137+
138+ if s. trim ( ) . is_empty ( ) && meta_syntax. stub_end . is_match ( & s) {
139+ // empty oneliner stubs are replaced by a newline
140+ return Some ( Ok ( MetaString :: Stub ( "\n " . to_string ( ) ) ) ) ;
141+ }
142+
143+ // save the syntax that started the current stub
144+ self . in_stub = Some ( meta_syntax) ;
145+
140146 if s. trim ( ) . is_empty ( ) {
141147 // only metadata, skip
142148 return self . next ( ) ;
@@ -155,7 +161,6 @@ impl<B: BufRead> Iterator for MetaSyntaxParser<B> {
155161 . stub_end
156162 . replace ( & s, |caps : & Captures | caps[ 1 ] . to_string ( ) )
157163 . to_string ( ) ;
158- log:: debug!( "parsed: '{}'" , s) ;
159164 if s. trim ( ) . is_empty ( ) {
160165 // only metadata, skip
161166 return self . next ( ) ;
@@ -338,16 +343,16 @@ print("a")
338343 MetaString :: stub( "class Kauppalista:\n " ) ,
339344 MetaString :: stub( " def __init__(self):\n " ) ,
340345 MetaString :: stub( " self.tuotteet = []\n " ) ,
341- MetaString :: stub( " \n " ) ,
346+ MetaString :: stub( "\n " ) ,
342347 MetaString :: stub( " def tuotteita(self):\n " ) ,
343348 MetaString :: stub( " return len(self.tuotteet)\n " ) ,
344- MetaString :: stub( " \n " ) ,
349+ MetaString :: stub( "\n " ) ,
345350 MetaString :: stub( " def lisaa(self, tuote: str, maara: int):\n " ) ,
346351 MetaString :: stub( " self.tuotteet.append((tuote, maara))\n " ) ,
347- MetaString :: stub( " \n " ) ,
352+ MetaString :: stub( "\n " ) ,
348353 MetaString :: stub( " def tuote(self, n: int):\n " ) ,
349354 MetaString :: stub( " return self.tuotteet[n - 1][0]\n " ) ,
350- MetaString :: stub( " \n " ) ,
355+ MetaString :: stub( "\n " ) ,
351356 MetaString :: stub( " def maara(self, n:int):\n " ) ,
352357 MetaString :: stub( " return self.uotteet[n - 1][1]\n " ) ,
353358 ] ;
0 commit comments