diff --git a/scripts/merge_by_toc.py b/scripts/merge_by_toc.py
index 14137f5ca801b..adcdbc384af73 100755
--- a/scripts/merge_by_toc.py
+++ b/scripts/merge_by_toc.py
@@ -214,6 +214,27 @@ def replace_heading(match):
return replace_heading
+# remove / tags for PDF output
+sticky_header_table_pattern = re.compile(r'^\s*?StickyHeaderTable\s*/?>\s*$')
+
+def remove_sticky_header_table(text):
+ lines = text.split('\n')
+ result = []
+ i = 0
+ while i < len(lines):
+ if sticky_header_table_pattern.match(lines[i]):
+ prev_blank = len(result) > 0 and result[-1].strip() == ''
+ next_blank = i + 1 < len(lines) and lines[i + 1].strip() == ''
+ if prev_blank and next_blank:
+ i += 2
+ else:
+ i += 1
+ else:
+ result.append(lines[i])
+ i += 1
+ return '\n'.join(result)
+
+
# remove copyable snippet code
def remove_copyable(match):
return ""
@@ -233,6 +254,7 @@ def remove_copyable(match):
chapter = replace_variables(chapter, variables)
chapter = replace_link_wrap(chapter, name)
chapter = copyable_snippet_pattern.sub(remove_copyable, chapter)
+ chapter = remove_sticky_header_table(chapter)
chapter = extract_custom_ids_and_clean(chapter)
chapter = replace_custom_id_links(chapter)
# This block is to filter xxx