()
| 53 | if "{{" not in text: |
| 54 | return text |
| 55 | parts = [] |
| 56 | i = 0 |
| 57 | for m in re.finditer(r'\{\{[\s\S]*?\}\}', text): |
| 58 | if m.start() < i: |
| 59 | continue |
| 60 | before = text[max(0, m.start() - 20) : m.start()] |
| 61 | if before.endswith("<span v-pre>"): |
| 62 | continue |
| 63 | parts.append(text[i : m.start()]) |
| 64 | parts.append(f"<span v-pre>{m.group(0)}</span>") |
| 65 | i = m.end() |
| 66 | parts.append(text[i:]) |
| 67 | return "".join(parts) |
| 68 | |
| 69 | |
| 70 | def sync_page(docs_path: Path, zh_fulltext_path: Path, dry_run: bool = False) -> bool: |
| 71 | if not docs_path.exists(): |
| 72 | return False |
| 73 | if not zh_fulltext_path.exists(): |
| 74 | return False |
| 75 | |
| 76 | page_text = docs_path.read_text(encoding="utf-8") |
| 77 | marker_pos = page_text.find(FULLTEXT_MARKER) |
| 78 | if marker_pos == -1: |
| 79 | return False |
| 80 |
no test coverage detected