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

Return nested elements as array #6

Open
leandroz opened this issue Apr 8, 2017 · 0 comments
Open

Return nested elements as array #6

leandroz opened this issue Apr 8, 2017 · 0 comments

Comments

@leandroz
Copy link

leandroz commented Apr 8, 2017

Hi!, what I am trying to implement is parsing a ul that can have deeper levels like:

<ul>
  <li><a>Title Page</a></li>
  <li><a>Copyright Page</a></li>
  <li><a>Dedication Page</a></li>
  <li>
    <a>Preface: About this edition</a>
    <ul>
      <li><a>#1. Let’s face it: It’s old</a></li>
      <li><a>#2. The world has changed</a></li>
      <li><a>Don’t get me wrong...</a></li>
    </ul>
  </li>
   <li><a>Index</a></li>
</ul>

The idea is to get something like:

{
  text: '',
  href: '',
  children: [
    {
      text: '',
      href: '',
      children: []
    }
  ]
}

Any idea how to apply recursion?

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

No branches or pull requests

1 participant