WikiExtractor / WikiExtractor/wikiextractor

Section header is printed even without --sections if list is first thing in section

Open Beginner friendly
#118 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
4k
Forks
1k
Avg merge
1m
Merged PRs (30d)
10

Description

If you have an article that looks like this:

===Section header===

*List item 1
*List item 2

And you pass the --lists argument, the section header will be included in the output even if you do not include the --sections argument. The reason is that the code in compact() that outputs the headers before a list does not check whether keepSections is true. Here is the relevant code:

            if line:  # FIXME: n is '"'
                if options.keepLists:
                    # emit open sections
                    items = sorted(headers.items())
                    for _, v in items:
                        page.append(v)
                    headers.clear()

I think it should be like this:

            if line:  # FIXME: n is '"'
                if options.keepLists:
                    if options.keepSections:
                        # emit open sections
                        items = sorted(headers.items())
                        for _, v in items:
                            page.append(v)
                    headers.clear()

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating compact() and inspect the keepLists handling described in the issue. Reproduce the example with --lists but without --sections, then verify that the section header is omitted while list items remain in the output. Check the existing command-line tests or add coverage for this option combination if no test covers it.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.