突出显示文本或XML以进行注释

时间:2018-11-14 20:56:45

标签: google-apps-script google-docs highlight

我有一个很长的文本,其中包含许多注释,这些注释可以从特定文本以粗体或XML标签创建:

Lorem ipsum dolor坐下,保密ad 高雅。

或者我也可以这样格式化:

<.XML.>Lorem< /XML.> ipsum dolor sit amet, <.XML>consectetur adipiscing< /XML> elit.

请问我如何将文本转换为高亮或粗体或XML标记等...

使用应用程序脚本在Google文档中添加注释吗?

Google文档的最终结果需要像这样: https://photos.app.goo.gl/pUugcKRHupqzZepBA

非常感谢您阅读!

在这里我找到一些文档:

Google Script

Some post

1 个答案:

答案 0 :(得分:0)

我向您展示了如何将Adobe InDesign索引转换为Word或Google Doc注释。

1º视频: https://youtu.be/_M1TaOgCYkU

2º图片库: https://photos.app.goo.gl/W2uvndiyujFby1X8A

3ºADOBE独立脚本:

// Project name: id0000131-convert-index-entries-into-Word-or-Google-Doc-comments
// Github: Adobe Indesign Script examples: https://github.com/firedevelop/id0000013-Adobe-InDesign-Scripts-Examples
// Github of this project: id0000131-convert-adobe-indesign-index-into-Word-or-Google-Doc-comments
// YouTube Playlist: https://www.youtube.com/playlist?list=PLfdbMQ5CoohPqK8ekjthm2fNoGMLwYeFf
// Blog: https://www.firedevelop.com/2018/11/id0000131-convert-index-entries-into.html

// Script Author:
// Peter Kahrel -- www.kahrel.plus.com
// http://www.kahrel.plus.com/indesign/index-to-text.jsx
// http://www.kahrel.plus.com/indesign/index_to_text.html



(function () {

    function addSortOrder (topic) {
        var s = topic.name;
        if (topic.sortOrder !== '') {
            s += '@' + topic.sortOrder;
        }
        return s;
    }

    function topicPath (topic, str) {
        if (topic.parent.constructor.name == 'Index') {
            return str;
        } else {
            return topicPath (topic.parent, addSortOrder (topic.parent) + '#' + str);
        }
    }

    function main () {
        var i, j;
        var topics;
        var err = false;
        if (app.documents[0].indexes.length === 0) {
            alert ('Document doesn\'t have an index.');
            exit();
        }
        topics = app.documents[0].indexes[0].allTopics;
        for (i = topics.length-1; i >= 0; i--) {
            for (j = topics[i].pageReferences.length-1; j > -1; j--) {
                try {
                    topics[i].pageReferences[j].sourceText.contents = '<!-- ' + topicPath (topics[i], addSortOrder (topics[i])) + ' -->';
                    //topics[i].pageReferences[j].remove();
                } catch (_) {
                    err = true;
                }
            }
        }
        if (err) {
            alert ('Some markers could not be converted. Please check the Index panel');
        }
    }

    main();

}());