我正在使用一个脚本来替换Google文档模板中的字符串。如果我使用\n
命令,我可以在模板中获得一个新行。
sample = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. \n Lorem Ipsum is simply dummy text of the printing and typesetting industry."
我得到这样的东西:
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
但是我想添加一个新字符串,而不是一个新段落(根据模板设置):
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
有一些方法可以做到吗?
答案 0 :(得分:1)
您无法在段落内容中创建段落,请在脚本中将字符串切片,在脚本中使用appendParagraph方法。
答案 1 :(得分:-1)
sample = "<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.
</p><p> Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>"
如果你想要段落的字符串部分,这将有效。如果没有,您可以将/n
替换为字符串
</p><p>