Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Fix algolia index title refer #2125

Merged
merged 3 commits into from
Sep 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 25 additions & 23 deletions scripts/index_algolia.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,38 +26,40 @@ def parse_pages(html_build_dir):

with open(filepath) as file:
doc = BeautifulSoup(file.read(), 'html.parser')

#set initial value for title
title = doc.title.text
elements = doc.select('div.article-container')[0]

# Extract title from h1 tag and remove it
for h1 in elements.select('h1'):
# Decompose the a tag in the h1 tag
for a in h1.select('a'):
a.decompose()
if elements:
# Extract title from h1 tag and remove it
for h1 in elements.select('h1'):
# Decompose the a tag in the h1 tag
for a in h1.select('a'):
a.decompose()

title = h1.text.strip()
h1.decompose()
title = h1.text.strip()
h1.decompose()

# remove admonition
for admonition in elements.select('div.admonition'):
admonition.decompose()
# remove admonition
for admonition in elements.select('div.admonition'):
admonition.decompose()

# remove tables of contents
for toc in elements.select('div.toctree-wrapper'):
toc.decompose()
# remove tables of contents
for toc in elements.select('div.toctree-wrapper'):
toc.decompose()

# remove header links
for headerlink in elements.select('a.headerlink'):
headerlink.decompose()
# remove header links
for headerlink in elements.select('a.headerlink'):
headerlink.decompose()

# remove preamble links etc
for backtotop in elements.select('a.back-to-top'):
backtotop.decompose()
# remove preamble links etc
for backtotop in elements.select('a.back-to-top'):
backtotop.decompose()

for icons in elements.select('div.content-icon-container'):
icons.decompose()
for icons in elements.select('div.content-icon-container'):
icons.decompose()

body = elements.text.strip()
body = elements.text.strip()
pages.append({
'title': title,
'body': body,
Expand Down
Loading