Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Python scraper to keep empty spans with ids #2082

Merged
merged 2 commits into from
Jan 5, 2024

Conversation

thewheat
Copy link
Contributor

Fixes #1081

Source has 3 IDs
image

Scraped page has 2
image

Turns out that

Code changes done

  • Created new sphinx_keep_empty_ids parameter to bypass sphinx/clean_html processing and set python scraper to options[:sphinx_keep_empty_ids] = true
  • options[:clean_text] = false to bypass core/clean_text

Other notes

In testing this solve the issue mentioned and likely other scenarios (could be up to 54 scenarios in total)

➜  python~3.10 git:(allow-python-empty-spans) ✗ pwd
/Users/thewheat/src/devdocs/docs/python~3.10
➜  python~3.10 git:(allow-python-empty-spans) ✗ grep -irn  "<span id=.*</span><span id="  | grep datetime
./library/datetime.html:2660:<span id="strftime-strptime-behavior"></span><span id="index-0"></span><h2><code class="xref py py-meth docutils literal notranslate"><span class="pre">strftime()</span></code> and <code class="xref py py-meth docutils literal notranslate"><span class="pre">strptime()</span></code> Behavior<a class="headerlink" href="#strftime-and-strptime-behavior" title="Permalink to this headline">¶</a></h2>
➜  python~3.10 git:(allow-python-empty-spans) ✗ grep -irn  "<span id=.*</span><span id="  | wc -l        
      54

Some others affected that are fixed in my local setup

Copy link
Contributor

@simon04 simon04 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thank you!

@simon04 simon04 merged commit 783e5dc into freeCodeCamp:main Jan 5, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Python datetime strftime/strptime behaviour link-to broken
2 participants