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

Deprecate tests for details and sections #1866

Open
VadimKovalenkoSNF opened this issue Jul 24, 2023 · 2 comments
Open

Deprecate tests for details and sections #1866

VadimKovalenkoSNF opened this issue Jul 24, 2023 · 2 comments
Labels
Milestone

Comments

@VadimKovalenkoSNF
Copy link
Collaborator

Current tests expect that sections and details will be removed if they have only summary tag inside without empty paragraph inside. The option keepEmptyParagraphs is responsible for removing these elements. The source code of it is:

/* Remove empty paragraphs */
  if (!dump.opts.keepEmptyParagraphs) {
    // Mobile view === details
    // Desktop view === section
    const sections: DominoElement[] = Array.from(parsoidDoc.querySelectorAll('details, section'))
    for (const section of sections) {
      if (
        section.children.length ===
        Array.from(section.children).filter((child: DominoElement) => {
          return child.matches('summary')
        }).length
      ) {
        DU.deleteNode(section)
      }
    }
  }

Consider this HTML is an example:

    <section>
        <summary>Section Summary</summary>
    </section>
    <details>
        <summary>Details Summary</summary>
    </details>
    <section>
        <summary>Section Summary</summary>
        <p>Some content</p>
    </section>
    <details>
        <summary>Details Summary</summary>
        <p>Some content</p>
    </details>

After transformation, the first section and details elements will be removed, as they only contain summary children. So the final output will look like this:

    <section>
        <summary>Section Summary</summary>
        <p>Some content</p>
    </section>
    <details>
        <summary>Details Summary</summary>
        <p>Some content</p>
    </details>

Current Parsoid version doesn't have the support of details tags (see https://phabricator.wikimedia.org/T31118) so keepEmptyParagraphs should be refactored with related unit tests since we expect to use page/html and page/mobile-html for desktop and mobile view respectively.

@VadimKovalenkoSNF
Copy link
Collaborator Author

Sidenote: Page with details and summary example can be found in Kiwix library here - http://library.kiwix.org/content/wikipedia_en_all_maxi/A/Perturbation_theory_(quantum_mechanics)
See #1501 for more details.

@kelson42 kelson42 added the bug label Jul 24, 2023
@kelson42 kelson42 added this to the 2.0.0 milestone Jul 24, 2023
@VadimKovalenkoSNF
Copy link
Collaborator Author

Upd: conversion to <details> and <sections> requires mobile-section endpoint working and happens in mwoffliner using res/templates/subsection_wrapper.html swig template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants