Skip to content

Instantly share code, notes, and snippets.

@kemsakurai
Created March 30, 2025 04:55
Show Gist options
  • Select an option

  • Save kemsakurai/5accf1fa87147f177f00589fa7384edc to your computer and use it in GitHub Desktop.

Select an option

Save kemsakurai/5accf1fa87147f177f00589fa7384edc to your computer and use it in GitHub Desktop.
gas-kindle-to-notion の作成に利用した。GitHub Copilot edits のプロンプト

以下の仕様で動作するclaspのGASアプリケーションを生成してください。

仕様

  • Gmailをポーリングし、特定のラベルが付与されたEmailを取得する。
  • そのEmailにはkindleのハイライトのエクスポート結果のHTMLが添付されている。
  • 添付されたHTMLは、以下のような形式である。
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
"XHTML1-s.dtd" >
<html xmlns="http://www.w3.org/TR/1999/REC-html-in-xml" xml:lang="en" lang="en">
    <head>
    <meta charset="UTF-8">
    <style>
        .bodyContainer {
            font-family: Arial, Helvetica, sans-serif;
            text-align: center;
            padding-left: 32px;
            padding-right: 32px;
        }
        
        .notebookFor {
            font-size: 18px;
            font-weight: 700;
            text-align: center;
            color: rgb(119, 119, 119);
            margin: 24px 0px 0px;
            padding: 0px;
        }
        
        .bookTitle {
            font-size: 24px;
            font-weight: 700;
            text-align: center;
            color: #333333;
            margin-top: 22px;
            padding: 0px;
        }
        
        .authors {
            font-size: 18px;
            font-weight: 700;
            text-align: center;
            color: rgb(119, 119, 119);
            margin-top: 22px;
            margin-bottom: 24px;
            padding: 0px;
        }
    
        .citation {
            font-size: 18px;
            font-weight: 500;
            text-align: center;
            color: #333333;
            margin-top: 22px;
            margin-bottom: 24px;
            padding: 0px;
        }
    
        .sectionHeading {
            font-size: 24px;
            font-weight: 700;
            text-align: left;
            color: #333333;
            margin-top: 24px;
            padding: 0px;
        }
        
        .noteHeading {
            font-size: 18px;
            font-weight: 700;
            text-align: left;
            color: #333333;
            margin-top: 20px;
            padding: 0px;
        }
        
        .noteText {
            font-size: 18px;
            font-weight: 500;
            text-align: left;
            color: #333333;
            margin: 2px 0px 0px;
            padding: 0px;
        }
        
        .highlight_blue {
            color: rgb(178, 205, 251);
        }
        
        .highlight_orange {
            color: #ffd7ae;
        }
        
        .highlight_pink {
            color: rgb(255, 191, 206);
        }
        
        .highlight_yellow {
            color: rgb(247, 206, 0);
        }
        
        .notebookGraphic {
            margin-top: 10px;
            text-align: left;
        }
        
        .notebookGraphic img {
            -o-box-shadow:      0px 0px 5px #888;
            -icab-box-shadow:   0px 0px 5px #888;
            -khtml-box-shadow:  0px 0px 5px #888;
            -moz-box-shadow:    0px 0px 5px #888;
            -webkit-box-shadow: 0px 0px 5px #888;
            box-shadow:         0px 0px 5px #888; 
            max-width: 100%;
            height: auto;
        }
        
        hr {
            border: 0px none;
            height: 1px;
            background: none repeat scroll 0% 0% rgb(221, 221, 221);
        }
        </style>
        <script>
            </script>
    </head>
    <body>
        <div class="bodyContainer">
            <div class="notebookFor">
                ノートブックのエクスポート
            </div>
            <div class="bookTitle">
                Effective DevOps
            </div>
            <div class="authors">
                Jennifer Davis、Ryn Daniels 著、吉羽 龍太郎 監訳、長尾 高弘 訳
            </div>
            <div class="citation">
                
            </div>
            <hr />
            <div class="sectionHeading">
    3章 devopsの歴史
</div><div class="noteHeading">
    ハイライト(<span class="highlight_pink">ピンク</span>) - 3.7 ソフトウェア開発手法の発展 > ページ23 ·位置607
</div>
<div class="noteText">
    アジャイルソフトウェア開発宣言の起草者のひとりでソフトウェア開発者のアリスター ・コー バーンは、成功しているチームについて 10年間研究を続けていた。そして、 2004年に、研究結果 にもとづいて、小さなチームのためのソフトウェア開発手法をまとめた 『Crystal Clear†5』(クリ スタルクリア)を発表した。同書では、成功しているチームに共通する性質として次の 3つをあげ ている。  ●使えるコードを頻繁に届ける。大きなデプロイをたまに行うのではなく、小さなデプロイ を頻繁に行うようにする  ●ふりかえりによる改善。直近の仕事でうまくいったこと、うまくいかなかったことをふり かえり、今後の仕事に活かす  ●開発者間の浸透的なコミュニケーション。開発者たちが同じ部屋にいれば、情報は自然に 流れ出して知らず知らずのうちに伝わる。それを浸透という言葉で表現したもの この運動はソフトウェア開発の世界で数年間続いたあと、影響の範囲を広げていった。同じ頃、 
</div><div class="sectionHeading">
    4章 基本的な用語と概念
</div><div class="noteHeading">
    ハイライト(<span class="highlight_pink">ピンク</span>) - 4.1 ソフトウェア開発手法 > ページ29 ·位置660
</div>
<div class="noteText">
    チーム の仕事がその手法のプロセスや目標に合わないときには怒りや不満を生むことにもなる。しかし、 さまざまな手法がどのように機能し、どのような効果が得られるかを理解すれば、この摩擦を理解 し、緩和するために役立つ。 
</div><div class="noteHeading">
    ハイライト(<span class="highlight_pink">ピンク</span>) - 4.3 システム手法 > ページ33 ·位置690
</div>
        </div>
    </body>
</html>
  • 上記のHTMLをparseして、Notion文書として、APIを利用して登録する。
  • HTMLでclass属性、"bookTitle"が指定されている要素のテキストをNotionのタイトルとして登録する。
  • HTMLでclass属性、"noteHeading"が指定されている要素のテキストをNotionのヘッディングとして登録する。
  • HTMLでclass属性、"noteText"が指定されている要素のテキストをNotionのテキストとして登録する。
  • HTMLでclass属性、"highlight_orange"が指定されている要素のテキストをNotionのハイライトとして登録する。
  • NotionのAPIを利用するためのトークンは、環境変数などで指定できるようにする。
  • NotionのAPIを利用するためのデータベースIDは、設定ファイルなどで指定できるようにする。
  • Notionに文書登録した対象のメールはスクリプトの最後で削除する。
  • スクリプトの実行結果は、ログファイルに出力する。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment