(positions)
| 165 | return mediabox, rect, None |
| 166 | |
| 167 | def contentfn(positions): |
| 168 | ret = '' |
| 169 | ret += textwrap.dedent(''' |
| 170 | <!DOCTYPE html> |
| 171 | <body> |
| 172 | <h2>Contents</h2> |
| 173 | <ul> |
| 174 | ''') |
| 175 | for position in positions: |
| 176 | if position.heading and (position.open_close & 1): |
| 177 | text = position.text if position.text else '' |
| 178 | if position.id: |
| 179 | ret += f' <li><a href="#{position.id}">{text}</a>' |
| 180 | else: |
| 181 | ret += f' <li>{text}' |
| 182 | ret += f' page={position.page_num}\n' |
| 183 | ret += '</ul>\n' |
| 184 | ret += textwrap.dedent(f''' |
| 185 | <h1>First section</h1> |
| 186 | <p>Contents of first section. |
| 187 | <ul> |
| 188 | <li>External <a href="https://artifex.com/">link to https://artifex.com/</a>. |
| 189 | <li><a href="#idtest">Link to IDTEST</a>. |
| 190 | <li><a href="#nametest">Link to NAMETEST</a>. |
| 191 | </ul> |
| 192 | |
| 193 | <h1>Second section</h1> |
| 194 | <p>Contents of second section. |
| 195 | <h2>Second section first subsection</h2> |
| 196 | |
| 197 | <p>Contents of second section first subsection. |
| 198 | <p id="idtest">IDTEST |
| 199 | |
| 200 | <h1>Third section</h1> |
| 201 | <p>Contents of third section. |
| 202 | <p><a name="nametest">NAMETEST</a>. |
| 203 | |
| 204 | </body> |
| 205 | ''') |
| 206 | return ret.strip() |
| 207 | |
| 208 | document = pymupdf.Story.write_stabilized_with_links(contentfn, rectfn) |
| 209 |
no outgoing calls
no test coverage detected
searching dependent graphs…