This repository houses custom Google Apps Script projects developed to enhance and automate our workflows within Google Workspace applications.
This project is licensed under the BSD-3-Clause License - see the LICENSE file for details.
This script is designed to apply default styles to Google Docs, with a particular focus on normalizing list items and ensuring formatting consistency across documents. It addresses the challenge of maintaining a uniform look and feel in dynamically generated or collaboratively edited documents.
- Resets styles to default for paragraphs and list items.
- Adjusts list item indents based on nesting level for visual clarity.
- Applies consistent text formatting across different document sections.
- Open a Google Doc.
- Navigate to
Extensions > Apps Script
. - Copy and paste the script code into the script editor and save.
- Refresh your Google Doc and access the script via
Custom Scripts
in the toolbar.
Due to Google Docs API constraints, the script encounters several limitations:
- Style Application: The API does not permit fetching or applying the exact default styles programmatically as the Google Docs UI does. Consequently, some styles, such as specific indents and spacing after paragraphs, are approximated based on observed defaults and may not match the UI's "Normal text" setting precisely.
- Inline Style Preservation: While inline styles are lost by the UI when reapplying styles to a block, I would perfer it they didn't. However, I didn't find a way to make that happen, at this point.
- List Item Handling: Google Docs API provides limited control over list styling, particularly with regard to bullet sizes and list item padding. The script makes best-effort adjustments within these constraints.
- Performance: The script's execution time may vary depending on the document's length and complexity, with longer documents potentially experiencing slower processing times.
This section will be updated with additional scripts as they are developed.
We welcome contributions and suggestions to improve our scripts, especially if you found a way to work around the API limitations. Please feel free to fork the repository, make changes, and submit pull requests. For major changes or new script proposals, please open an issue first to discuss what you would like to change.
These scripts are offered as is.