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 sections - Google Docs Tutorial
From the course: Google Apps Script for JavaScript Developers
Parsing sections
- [Instructor] Now it's time for us to start taking the first steps into formatting all of this raw text. Let's go back into our convertToMarkdown script project. And go to our Doc2Markdown script. We're going to create a new function, so that we can parse each of the sections we pull out from the Google Doc. We'll call this function parseSection and we'll pass in a reference to the section's child. In our convertToMarkdown, let's go ahead and change where we add the text.getsection to equal parseSection, and pass in the section itself. We can either comment out, or delete the call to where we get the text. Now let's add some new lines so that we can add some logic to our parseSection function. The first thing we're going to do here is create a new variable called text and we're going to set it equal to an empty string. At the bottom of our method, we're going to call text plus slash n as a string so that we have a new line break. Let's save this and go into our main script, and run…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.