|
37 | 37 | EXTERNAL_LINK_RE = re.compile( |
38 | 38 | "[\./]*([\w_-]+)/[\w_/-]*?([\w_.-]*\.(?:html|adoc))", re.DOTALL |
39 | 39 | ) |
40 | | -INCLUDE_RE = re.compile("include::(.*?)\[(.*?)\]", re.M) |
| 40 | +INCLUDE_RE = re.compile(r"^include::(.*?)\[(.*?)\]", re.M) |
41 | 41 | IFDEF_RE = re.compile(r"^if(n?)def::(.*?)\[\]", re.M) |
42 | 42 | ENDIF_RE = re.compile(r"^endif::(.*?)\[\]\r?\n", re.M) |
43 | 43 | COMMENT_CONTENT_RE = re.compile(r"^^////$.*?^////$", re.M | re.DOTALL) |
| 44 | +COMMENTED_XREF_RE = re.compile(r"^//.*xref:.*$") |
44 | 45 | TAG_CONTENT_RE = re.compile( |
45 | 46 | r"//\s+tag::(.*?)\[\].*?// end::(.*?)\[\]", re.M | re.DOTALL |
46 | 47 | ) |
@@ -625,10 +626,19 @@ def scrub_file(info, book_src_dir, src_file, tag=None, cwd=None): |
625 | 626 | # data that it finds. |
626 | 627 | # modified 20/Aug/2024 to process https links which are preceded |
627 | 628 | # by an added directory (happens with hugeBook) |
| 629 | + # Modified 05/Dec/2024 to allow for https links from openshift-kni repo. |
628 | 630 |
|
| 631 | + # Check for both allowed URL patterns |
629 | 632 | https_pos = base_src_file.find("https://raw.githubusercontent.com/openshift/") |
630 | | - if https_pos >=0: |
631 | | - base_src_file = base_src_file[https_pos:] |
| 633 | + https_kni_pos = base_src_file.find("https://raw.githubusercontent.com/openshift-kni/") |
| 634 | + |
| 635 | + if https_pos >= 0 or https_kni_pos >= 0: |
| 636 | + # Ensure we start from the correct URL (either github or openshift-kni) |
| 637 | + if https_kni_pos >= 0: |
| 638 | + base_src_file = base_src_file[https_kni_pos:] |
| 639 | + else: |
| 640 | + base_src_file = base_src_file[https_pos:] |
| 641 | + |
632 | 642 | try: |
633 | 643 | response = requests.get(base_src_file) |
634 | 644 | if response: |
@@ -656,6 +666,9 @@ def scrub_file(info, book_src_dir, src_file, tag=None, cwd=None): |
656 | 666 | if line.strip() == "" and not content_found: |
657 | 667 | continue |
658 | 668 |
|
| 669 | + # Replace lines containing commented xrefs |
| 670 | + line = COMMENTED_XREF_RE.sub("// Removed commented line that contains an xref", line) |
| 671 | + |
659 | 672 | # Check if the line should be included in the output |
660 | 673 | if include_line(line): |
661 | 674 | content_found = True |
|
0 commit comments