【发布时间】:2013-09-11 18:28:40
【问题描述】:
问题:如何阅读 google docs doc 中的标题参考(格式为 #heading=h.12345)?
背景:希望在 doc 中使用交叉引用。示例。
1.1 Chapter 1 (i.e. paragraph has heading DocumentApp.ParagraphHeading.HEADING1)
Sample text. For more, see chapter 1.2.
1.2 Chapter 2
Sample text. For more, see chapter 1.1.
现在,谷歌文档可以进行交叉引用(插入链接),但属于“普通”链接,不带有章节号。
因此,方法是: - 插入交叉引用的链接
使用应用程序脚本,构建标题引用和章节编号的索引
还有应用程序脚本,更新参见基于其链接的章节文本
我查看了getLinkUrl没有成功:
var links = [];
var ps = DocumentApp.getActiveDocument().getBody().getParagraphs();
for(var i = 0; i < ps.length; i++) {
var h = ps[i].getHeading();
if( h == DocumentApp.ParagraphHeading.HEADING1 ) {
var t = ps[i].editAsText();
var u = t.getLinkUrl();
}
}
是否可以读取标题参考?
【问题讨论】:
标签: google-apps-script google-docs google-docs-api