From the course: Google Apps Script for JavaScript Developers

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Parsing elements

Parsing elements - Google Docs Tutorial

From the course: Google Apps Script for JavaScript Developers

Start my 1-month free trial

Parsing elements

- [Narrator] Now we're ready to start formatting more of our Markdown text. As you can see, our spacing isn't correct and we have gaps where our images are supposed to go. In order to fix this, we're going to need to understand more about a section's child elements. Let's switch back over to our convert-to-Markdown project and look at our doc-to-Markdown script. Let's go ahead and add a new function to the bottom of our script. We're going to call this function parseElement, and we're going to pass in an element as an argument. Now previously, we were simply getting the section's text. But, each section actually contains children elements. Now each of these elements could represent an image, or more text, or even tables and lists. Let's go ahead and delete our call to text plus equals section dot get text. Instead, we're going to want to go through and find all the children in the section. Since we're already getting the number of children, let's go ahead and create a new for loop…

Contents