diff --git a/sphinxcontrib/confluencebuilder/publisher.py b/sphinxcontrib/confluencebuilder/publisher.py index 160a130f..38f31cf8 100644 --- a/sphinxcontrib/confluencebuilder/publisher.py +++ b/sphinxcontrib/confluencebuilder/publisher.py @@ -550,12 +550,13 @@ def get_page(self, page_name, expand='version', status='current'): 'title': page_name, }) else: - rsp = self.rest.get(f'{self.APIV1}content', { - 'type': 'page', - 'spaceKey': self.space_key, - 'title': page_name, - 'status': status, - 'expand': expand, + # Workaround for https://jira.atlassian.com/browse/CONFSERVER-57639: + # Hitting the base Content API endpoint can cause performance problem for large instances + rsp = self.rest.get(f'{self.APIV1}content/search', { + "cql": f"title='{page_name}'", + "cqlcontext": json.dumps({"contentStatuses": [status], "spaceKey": self.space_key}), + "expand": ["version"], + "limit": 1 }) if rsp['results']: diff --git a/sphinxcontrib/confluencebuilder/storage/translator.py b/sphinxcontrib/confluencebuilder/storage/translator.py index ef00cdb9..e48e74a3 100644 --- a/sphinxcontrib/confluencebuilder/storage/translator.py +++ b/sphinxcontrib/confluencebuilder/storage/translator.py @@ -1279,6 +1279,13 @@ def _visit_reference_intern_id(self, node): # identifier value instead target = self.state.target(anchorname) if target: + # Johannes Loibl: If multiple anchors are generated for the same reference (e.g. when an explicit reference + # is placed directly before a heading, Sphinx will generate two anchors and increase the suffix counter, + # e.g. HEADING, HEADING.1, HEADING.2, ... . This leads to a wrong naming of the final anchor link, + # since the heading can only be accessed via the root name (HEADING in this case). + # So we have to strip off the number suffix + if "." in target: + target = target.split(".")[0] anchor_value = target anchor_value = self.encode(anchor_value) else: