Most of the material concerning Google Apps Script on this site is about Google Spreadsheets. You can also use GAS to extend Google Documents. There is an exciting new capability called add-ons
Here’s an add-on for pinyin conversion.
Pinyin is an easy way of writing Mandarin Chinese using the Latin alphabet. It uses tone markers as a guide to pronunciation. However, it is difficult to enter these tone markers on a regular keyboard. That is why a system of tone numbers (1-5) can be used to imply particular tone marks. There is also a spreadsheet pinyin converter for Google Sheets or Excel on this site.