@@ -794,7 +794,7 @@ def export_to_document_tokens(
794794 :param add_content: bool: (Default value = True)
795795
796796 """
797- body = f"{ DocumentToken . BEG_CODE .value } { new_line } "
797+ body = f"< { self . label .value } { new_line } "
798798
799799 if add_location :
800800 body += self .get_location_tokens (
@@ -807,7 +807,7 @@ def export_to_document_tokens(
807807 if add_content and self .text is not None :
808808 body += f"<_{ self .code_language .value } _>{ self .text } { new_line } "
809809
810- body += f"{ DocumentToken . END_CODE .value } \n "
810+ body += f"</ { self . label .value } \n "
811811
812812 return body
813813
@@ -977,8 +977,7 @@ def export_to_document_tokens(
977977 :param # not used at the moment
978978
979979 """
980- body = f"{ DocumentToken .BEG_PICTURE .value } { new_line } "
981-
980+ body = f"<{ self .label .value } >{ new_line } "
982981 if add_location :
983982 body += self .get_location_tokens (
984983 doc = doc ,
@@ -1002,7 +1001,7 @@ def export_to_document_tokens(
10021001 text = self .caption_text (doc )
10031002
10041003 if len (text ):
1005- body += f"{ DocumentToken . BEG_CAPTION .value } "
1004+ body += f"< { DocItemLabel . CAPTION .value } > "
10061005 for caption in self .captions :
10071006 body += caption .resolve (doc ).get_location_tokens (
10081007 doc = doc ,
@@ -1011,10 +1010,10 @@ def export_to_document_tokens(
10111010 ysize = ysize ,
10121011 )
10131012 body += f"{ text .strip ()} "
1014- body += f"{ DocumentToken . END_CAPTION .value } "
1013+ body += f"</ { DocItemLabel . CAPTION .value } > "
10151014 body += f"{ new_line } "
10161015
1017- body += f"{ DocumentToken . END_PICTURE .value } \n "
1016+ body += f"</ { self . label .value } > \n "
10181017
10191018 return body
10201019
@@ -1294,8 +1293,11 @@ def export_to_document_tokens(
12941293 :param add_cell_location: bool: (Default value = True)
12951294 :param add_cell_text: bool: (Default value = True)
12961295 :param add_caption: bool: (Default value = True)
1296+
12971297 """
1298- body = f"{ DocumentToken .BEG_OTSL .value } { new_line } "
1298+ otsl_tag = DocumentToken .OTSL .value
1299+
1300+ body = f"<{ otsl_tag } >{ new_line } "
12991301
13001302 if add_location :
13011303 body += self .get_location_tokens (
@@ -1311,7 +1313,7 @@ def export_to_document_tokens(
13111313 text = self .caption_text (doc )
13121314
13131315 if len (text ):
1314- body += f"{ DocumentToken . BEG_CAPTION .value } "
1316+ body += f"< { DocItemLabel . CAPTION .value } > "
13151317 for caption in self .captions :
13161318 body += caption .resolve (doc ).get_location_tokens (
13171319 doc = doc ,
@@ -1320,10 +1322,10 @@ def export_to_document_tokens(
13201322 ysize = ysize ,
13211323 )
13221324 body += f"{ text .strip ()} "
1323- body += f"{ DocumentToken . END_CAPTION .value } "
1325+ body += f"</ { DocItemLabel . CAPTION .value } > "
13241326 body += f"{ new_line } "
13251327
1326- body += f"{ DocumentToken . END_OTSL . value } \n "
1328+ body += f"</ { otsl_tag } > \n "
13271329
13281330 return body
13291331
@@ -2777,9 +2779,9 @@ def _close_lists(
27772779 while current_level < previous_level and ordered_list_stack :
27782780 last_is_ordered = ordered_list_stack .pop ()
27792781 if last_is_ordered :
2780- output_parts .append ("</ordered_list >\n " )
2782+ output_parts .append (f "</{ DocumentToken . ORDERED_LIST . value } >\n " )
27812783 else :
2782- output_parts .append ("</unordered_list >\n " )
2784+ output_parts .append (f "</{ DocumentToken . UNORDERED_LIST . value } >\n " )
27832785 previous_level -= 1
27842786 return ordered_list_stack
27852787
@@ -2806,7 +2808,7 @@ def _add_page_break_if_needed(
28062808 return output_parts , current_page_no
28072809
28082810 if current_page_no != prev_page_no :
2809- output_parts .append (f"{ DocumentToken .PAGE_BREAK .value } \n " )
2811+ output_parts .append (f"< { DocumentToken .PAGE_BREAK .value } > \n " )
28102812
28112813 return output_parts , current_page_no
28122814
@@ -2832,7 +2834,7 @@ def _get_standalone_captions(document_body):
28322834 standalone_captions = _get_standalone_captions (self .body )
28332835
28342836 # Begin document
2835- output_parts .append (f"{ DocumentToken .BEG_DOCUMENT .value } { delim } " )
2837+ output_parts .append (f"< { DocumentToken .DOCUMENT .value } > { delim } " )
28362838
28372839 for ix , (item , current_level ) in enumerate (
28382840 self .iterate_items (
@@ -2868,10 +2870,12 @@ def _get_standalone_captions(document_body):
28682870 # Handle list groups
28692871 if isinstance (item , GroupItem ):
28702872 if item .label == GroupLabel .ORDERED_LIST :
2871- output_parts .append (f"<ordered_list >{ delim } " )
2873+ output_parts .append (f"<{ DocumentToken . ORDERED_LIST . value } >{ delim } " )
28722874 ordered_list_stack .append (True )
28732875 elif item .label == GroupLabel .LIST :
2874- output_parts .append (f"<unordered_list>{ delim } " )
2876+ output_parts .append (
2877+ f"<{ DocumentToken .UNORDERED_LIST .value } >{ delim } "
2878+ )
28752879 ordered_list_stack .append (False )
28762880 continue
28772881
@@ -2945,7 +2949,7 @@ def _get_standalone_captions(document_body):
29452949 )
29462950
29472951 # End document
2948- output_parts .append (DocumentToken .END_DOCUMENT .value )
2952+ output_parts .append (f"</ { DocumentToken .DOCUMENT .value } >" )
29492953
29502954 return "" .join (output_parts )
29512955
0 commit comments