(writer, contentfn, rectfn, user_css=None, em=12, positionfn=None, pagefn=None, archive=None, add_header_ids=True)
| 16033 | |
| 16034 | @staticmethod |
| 16035 | def write_stabilized(writer, contentfn, rectfn, user_css=None, em=12, positionfn=None, pagefn=None, archive=None, add_header_ids=True): |
| 16036 | positions = list() |
| 16037 | content = None |
| 16038 | # Iterate until stable. |
| 16039 | while 1: |
| 16040 | content_prev = content |
| 16041 | content = contentfn( positions) |
| 16042 | stable = False |
| 16043 | if content == content_prev: |
| 16044 | stable = True |
| 16045 | content2 = content |
| 16046 | story = Story(content2, user_css, em, archive) |
| 16047 | |
| 16048 | if add_header_ids: |
| 16049 | story.add_header_ids() |
| 16050 | |
| 16051 | positions = list() |
| 16052 | def positionfn2(position): |
| 16053 | #log(f"write_stabilized(): {stable=} {positionfn=} {position=}") |
| 16054 | positions.append(position) |
| 16055 | if stable and positionfn: |
| 16056 | positionfn(position) |
| 16057 | story.write( |
| 16058 | writer if stable else None, |
| 16059 | rectfn, |
| 16060 | positionfn2, |
| 16061 | pagefn, |
| 16062 | ) |
| 16063 | if stable: |
| 16064 | break |
| 16065 | |
| 16066 | @staticmethod |
| 16067 | def write_stabilized_with_links(contentfn, rectfn, user_css=None, em=12, positionfn=None, pagefn=None, archive=None, add_header_ids=True): |
no test coverage detected