问题:如何阅读 google docs doc 中的标题参考(格式为#heading=h.12345)?
背景:想在文档中使用交叉引用。例子。
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();
}
}
是否可以阅读标题参考?