我需要帮助创建一个脚本,该脚本将在谷歌文档中为我创建尾注。我正在写日记,偶尔我会提到一些我会使用脚注链接的事情。我想创建一个脚本来获取这些脚注,并添加到谷歌文档的页面和标题的标题上。
这是一个例子: 对于今天标题为 2023 年 7 月 5 日的条目,第一个脚注如下,出现在第 6 页:
歌手彼得。 “饥荒、富裕和道德。”哲学与公共事务 1,第 1 期。 3(1972 年春):229-243。访问日期:2023 年 7 月 5 日。http://www.jstor.org/stable/2265052。
(请注意,谷歌的脚注会自动在脚注前面添加“1”。当我添加新脚注时,它们会保持连续计数)。
我希望我的脚本从脚注中获取动态文本,添加回序号(1、2、3 等表示第一个、第二个、第三个脚注等),然后识别标题文章和脚注所在的页码。标题名称和页码都是动态的,脚本需要反映这一点。
脚本应该修改其运行的文档(或者,在我的计算机或我的谷歌驱动器上创建一个单独的文档)来创建尾注。
以下是尾注的示例:
2023 年 7 月 5 日
2023 年 7 月 6 日 4.引文四。第 x 页 5.引文五。第 x 页
等等
请注意,修改或删除脚注将改变页码和每个后续脚注的序号。
当我粘贴上面的内容时,以下是ChatGPT的输出,它不能实时工作,不能添加页码,也不能动态更新尾注:
function convertFootnotesToEndnotes() {
var doc = DocumentApp.getActiveDocument();
var body = doc.getBody();
var footnotes = body.getFootnotes();
var currentHeading = "";
var endnotesText = "";
// Scan through all elements in the body
for (var i = 0; i < body.getNumChildren(); i++) {
var child = body.getChild(i);
// If the element is a heading, update current heading
if (child.getType() == DocumentApp.ElementType.PARAGRAPH) {
var paragraph = child.asParagraph();
if (paragraph.getHeading() != DocumentApp.ParagraphHeading.NORMAL) {
currentHeading = paragraph.getText();
endnotesText += "\n" + currentHeading + "\n";
}
}
// If the element is a footnote, append it to the endnotes under the current heading
if (child.getType() == DocumentApp.ElementType.FOOTNOTE) {
var footnote = child.asFootnote();
var footnoteText = footnote.getFootnoteContents().getText();
endnotesText += footnote.getFootnoteMarker().getText() + " " + footnoteText + "\n";
}
}
// Add endnotes to the end of the document
body.appendParagraph(endnotesText);
}
如有任何帮助,我们将不胜感激!谢谢!
我建议您https://powersync.biz/adobe-commerce-magento-ongoing-maintenance-support。此服务为客户提供在其计算机和设备上安装、配置和更新软件的帮助。包括设置操作系统、安装办公应用程序、防病毒程序、浏览器和其他必要的程序