DEV Community

Bruce Axtens
Bruce Axtens

Posted on

How to get Google Apps Script to tell Google Docs to bold, italic, strikethrough and underline from a JSON representation?


I have written a function, setParagraphToRichText which accepts a GoogleAppsScript.Document.Paragraph and a string. The string is a stringified JSON blob that defines the text and attributes of a given paragraph.

 * @param {GoogleAppsScript.Document.Paragraph} paragraph
 * @param {string} jsonString
function setParagraphToRichText(paragraph, jsonString) {
  const text = paragraph.editAsText();

Top comments (1)

bugmagnet profile image
Bruce Axtens • Edited

Turns out it was a typo. So not Google's fault but mine. Sigh. Old and decrepit much.