14
14
from .usfm_parser import UsfmParser
15
15
from .usfm_parser_state import UsfmParserState
16
16
from .usfm_stylesheet import UsfmStylesheet
17
- from .usfm_token import UsfmAttribute , UsfmToken , UsfmTokenType
17
+ from .usfm_token import UsfmAttribute , UsfmTokenType
18
18
from .usfm_tokenizer import UsfmTokenizer
19
19
20
20
@@ -82,10 +82,8 @@ def __init__(self, text: UsfmTextBase) -> None:
82
82
83
83
self ._text = text
84
84
self ._rows : List [TextRow ] = []
85
- self ._next_para_tokens : List [UsfmToken ] = []
86
85
self ._row_texts_stack : List [str ] = []
87
86
self ._sentence_start : bool = False
88
- self ._next_para_text_started = False
89
87
90
88
@property
91
89
def rows (self ) -> Iterable [TextRow ]:
@@ -98,18 +96,6 @@ def start_book(self, state: UsfmParserState, marker: str, code: str) -> None:
98
96
if code != self ._text .id :
99
97
raise ValueError (f"The \\ id marker { code } does not match the text id { self ._text .id } ." )
100
98
101
- def verse (
102
- self ,
103
- state : UsfmParserState ,
104
- number : str ,
105
- marker : str ,
106
- alt_number : Optional [str ],
107
- pub_number : Optional [str ],
108
- ) -> None :
109
- super ().verse (state , number , marker , alt_number , pub_number )
110
- self ._next_para_text_started = True
111
- self ._next_para_tokens .clear ()
112
-
113
99
def start_para (
114
100
self ,
115
101
state : UsfmParserState ,
@@ -195,12 +181,6 @@ def text(self, state: UsfmParserState, text: str) -> None:
195
181
if self ._text ._include_markers :
196
182
text = text .rstrip ("\r \n " )
197
183
if len (text ) > 0 :
198
- if not text .isspace ():
199
- if self ._current_text_type == ScriptureTextType .VERSE :
200
- for token in self ._next_para_tokens :
201
- row_text += str (token ) + " "
202
- self ._next_para_tokens .clear ()
203
- self ._next_para_text_started = True
204
184
if len (row_text ) == 0 or row_text [- 1 ].isspace ():
205
185
text = text .lstrip ()
206
186
row_text += text
@@ -223,9 +203,6 @@ def _start_verse_text(self, state: UsfmParserState, scripture_refs: Sequence[Scr
223
203
224
204
def _end_verse_text (self , state : UsfmParserState , scripture_refs : Sequence [ScriptureRef ]) -> None :
225
205
text = self ._row_texts_stack .pop ()
226
- if self ._text ._include_markers :
227
- for token in self ._next_para_tokens :
228
- text += str (token ) + " "
229
206
self ._rows .extend (self ._text ._create_scripture_rows (scripture_refs , text , self ._sentence_start ))
230
207
self ._sentence_start = (state .token and state .token .marker == "c" ) or has_sentence_ending (text )
231
208
@@ -243,10 +220,7 @@ def _output_marker(self, state: UsfmParserState) -> None:
243
220
244
221
assert state .token is not None
245
222
246
- if self ._next_para_text_started :
247
- self ._row_texts_stack [- 1 ] += str (state .token )
248
- else :
249
- self ._next_para_tokens .append (state .token )
223
+ self ._row_texts_stack [- 1 ] += str (state .token )
250
224
251
225
def _handle_para (self , state : UsfmParserState ) -> None :
252
226
if len (self ._row_texts_stack ) == 0 :
@@ -257,8 +231,7 @@ def _handle_para(self, state: UsfmParserState) -> None:
257
231
for i , row_text in enumerate (self ._row_texts_stack ):
258
232
if len (row_text ) > 0 and not row_text [- 1 ].isspace ():
259
233
self ._row_texts_stack [i ] += " "
260
- if self ._current_text_type == ScriptureTextType .VERSE :
261
- self ._next_para_tokens .append (state .token )
262
- self ._next_para_text_started = False
234
+ if self ._current_text_type == ScriptureTextType .VERSE and self ._text ._include_markers :
235
+ self ._row_texts_stack [- 1 ] += str (state .token ) + " "
263
236
if not state .is_verse_para :
264
237
self ._sentence_start = True
0 commit comments