Initialize substitution patterns for asciidoctor xrefs to Antora resource IDs and add them to the remapPatterns object.
(remapState, remapPatterns)
| 452 | printFooter(fp, leveloffset) |
| 453 | |
| 454 | def xrefRewriteInitialize(remapState, remapPatterns): |
| 455 | """Initialize substitution patterns for asciidoctor xrefs to Antora |
| 456 | resource IDs and add them to the remapPatterns object.""" |
| 457 | |
| 458 | # These are xrefs to API entities, rewritten to link to refpages |
| 459 | # The refLink variants are for xrefs with only an anchor and no text. |
| 460 | # The refLinkText variants are for xrefs with both anchor and text |
| 461 | remapPatterns.refLinkPattern = re.compile(r'<<([Vv][Kk][A-Za-z0-9_]+)>>') |
| 462 | remapPatterns.refLinkTextPattern = re.compile(r'<<([Vv][Kk][A-Za-z0-9_]+)[,]?[ \t\n]*([^>,]*)>>') |
| 463 | |
| 464 | if remapState.antora: |
| 465 | remapPatterns.refLinkSubstitute = r'xref:\1.adoc[\1]' |
| 466 | remapPatterns.refLinkTextSubstitute = r'xref:\1.adoc[\2]' |
| 467 | else: |
| 468 | remapPatterns.refLinkSubstitute = r'link:\1.html[\1^]' |
| 469 | remapPatterns.refLinkTextSubstitute = r'link:\1.html[\2^]' |
| 470 | |
| 471 | # These are xrefs to other anchors, rewritten to link to the spec |
| 472 | remapPatterns.specLinkPattern = re.compile(r'<<([-A-Za-z0-9_.(){}:]+)[,]?[ \t\n]*([^>,]*)>>') |
| 473 | |
| 474 | # Unfortunately specLinkSubstitute depends on the link target, |
| 475 | # so must be generated for each target |
| 476 | remapPatterns.specLinkSubstitute = None |
| 477 | |
| 478 | def xrefRewrite(text, specURL): |
| 479 | """Rewrite asciidoctor xrefs in text to resolve properly in refpages. |