Dynalistから深さを指定してmarkdownにエクスポートするブックマークレット
で
learning-rust
# SQLiteのようなデータベースのストレージエンジンを実装する
# ファイルI/Oの実装:
# B-treeの実装:
# トランザクションログの実装:
# データ整合性の確保:
になる
ChatGPTに長文のアウトラインのみを与えたい時に使う
(function() {
var depth = prompt("Please enter the recursion depth", "1");
depth = parseInt(depth);
function child(x, y, z) {
if (y > depth) return z;
var s, h = y <= 1 ? y : 0, n = x.children(".Node-self").children(".Node-openNote").attr("title"), c = x.children(".Node-children").children(".Node-outer").children(".Node:not(.is-checked)");
c.length > 0 ? (z.push({
title: x.children(".Node-self").children(".Node-contentContainer").children(".Node-content").text().trim(),
node: y,
child: !0,
heading: h,
note: n
}), y += 1) : z.push({
title: x.children(".Node-self").children(".Node-contentContainer").children(".Node-content").text().trim(),
node: y,
child: !1,
heading: h,
note: n
});
for (var i = 0; i < c.length; i++) child(c.eq(i), y, z);
return z;
}
var list = [];
p = $(".is-currentRoot"), text = child(p, 0, list);
var titletxt = list[0].title, pnote = p.children(".Node-self").children(".Node-openNote").attr("title"), outtxt = pnote ? pnote + "\n\n" : "", unindent_lv = 0;
for (i = 1; i < list.length; i++) 0 != list[i].heading ? (outtxt += "\n" + "#".repeat(list[i].heading) + " " + list[i].title + "\n\n" + (list[i].note ? "\n" + list[i].note + "\n\n" : ""), unindent_lv = list[i].node + 1) : outtxt += (list[i].node - unindent_lv <= 0 ? "" : " ".repeat(4 * (list[i].node - unindent_lv))) + "- " + list[i].title + "\n" + (list[i].note ? "\n" + list[i].note + "\n\n" : "");
function escape_html(string) {
return "string" != typeof string ? string : string.replace(/[&'`"><]/g, function(match) {
return {
"&": "&",
"'": "'",
"`": "`",
'"': """,
"<": "<",
">": ">"
}[match];
});
}
w = window.open(), w.document.open(), w.document.write('<!DOCTYPE html><html lang="ja"><head><title>Dyn2Md</title><style type="text/css">textarea{width:100%;height:500px;}button{width:100%;height:50px}</style></head><body><button onclick="copyToClipboard()">copy and close</button><textarea id="ta">' + titletxt + "\n\n" + escape_html(outtxt) + '</textarea></body><script>function copyToClipboard(){var ta=document.getElementById("ta");ta.select();document.execCommand("Copy");window.close()}</script></html>'), w.document.close();
}());
コピペ用
javascript:(function()%7Bjavascript%3A(function()%20%7B%20var%20depth%20%3D%20prompt(%22Please%20enter%20the%20recursion%20depth%22%2C%20%221%22)%3B%20depth%20%3D%20parseInt(depth)%3B%20function%20child(x%2C%20y%2C%20z)%20%7B%20if%20(y%20%3E%20depth)%20return%20z%3B%20var%20s%2C%20h%20%3D%20y%20%3C%3D%201%20%3F%20y%20%3A%200%2C%20n%20%3D%20x.children(%22.Node-self%22).children(%22.Node-openNote%22).attr(%22title%22)%2C%20c%20%3D%20x.children(%22.Node-children%22).children(%22.Node-outer%22).children(%22.Node%3Anot(.is-checked)%22)%3B%20c.length%20%3E%200%20%3F%20(z.push(%7B%20title%3A%20x.children(%22.Node-self%22).children(%22.Node-contentContainer%22).children(%22.Node-content%22).text().trim()%2C%20node%3A%20y%2C%20child%3A%20!0%2C%20heading%3A%20h%2C%20note%3A%20n%20%7D)%2C%20y%20%2B%3D%201)%20%3A%20z.push(%7B%20title%3A%20x.children(%22.Node-self%22).children(%22.Node-contentContainer%22).children(%22.Node-content%22).text().trim()%2C%20node%3A%20y%2C%20child%3A%20!1%2C%20heading%3A%20h%2C%20note%3A%20n%20%7D)%3B%20for%20(var%20i%20%3D%200%3B%20i%20%3C%20c.length%3B%20i%2B%2B)%20child(c.eq(i)%2C%20y%2C%20z)%3B%20return%20z%3B%20%7D%20var%20list%20%3D%20%5B%5D%3B%20p%20%3D%20%24(%22.is-currentRoot%22)%2C%20text%20%3D%20child(p%2C%200%2C%20list)%3B%20var%20titletxt%20%3D%20list%5B0%5D.title%2C%20pnote%20%3D%20p.children(%22.Node-self%22).children(%22.Node-openNote%22).attr(%22title%22)%2C%20outtxt%20%3D%20pnote%20%3F%20pnote%20%2B%20%22%5Cn%5Cn%22%20%3A%20%22%22%2C%20unindent_lv%20%3D%200%3B%20for%20(i%20%3D%201%3B%20i%20%3C%20list.length%3B%20i%2B%2B)%200%20!%3D%20list%5Bi%5D.heading%20%3F%20(outtxt%20%2B%3D%20%22%5Cn%22%20%2B%20%22%23%22.repeat(list%5Bi%5D.heading)%20%2B%20%22%20%22%20%2B%20list%5Bi%5D.title%20%2B%20%22%5Cn%5Cn%22%20%2B%20(list%5Bi%5D.note%20%3F%20%22%5Cn%22%20%2B%20list%5Bi%5D.note%20%2B%20%22%5Cn%5Cn%22%20%3A%20%22%22)%2C%20unindent_lv%20%3D%20list%5Bi%5D.node%20%2B%201)%20%3A%20outtxt%20%2B%3D%20(list%5Bi%5D.node%20-%20unindent_lv%20%3C%3D%200%20%3F%20%22%22%20%3A%20%22%20%22.repeat(4%20*%20(list%5Bi%5D.node%20-%20unindent_lv)))%20%2B%20%22-%20%22%20%2B%20list%5Bi%5D.title%20%2B%20%22%5Cn%22%20%2B%20(list%5Bi%5D.note%20%3F%20%22%5Cn%22%20%2B%20list%5Bi%5D.note%20%2B%20%22%5Cn%5Cn%22%20%3A%20%22%22)%3B%20function%20escape_html(string)%20%7B%20return%20%22string%22%20!%3D%20typeof%20string%20%3F%20string%20%3A%20string.replace(%2F%5B%26'%60%22%3E%3C%5D%2Fg%2C%20function(match)%20%7B%20return%20%7B%20%22%26%22%3A%20%22%26amp%3B%22%2C%20%22'%22%3A%20%22%26%23x27%3B%22%2C%20%22%60%22%3A%20%22%26%23x60%3B%22%2C%20'%22'%3A%20%22%26quot%3B%22%2C%20%22%3C%22%3A%20%22%26lt%3B%22%2C%20%22%3E%22%3A%20%22%26gt%3B%22%20%7D%5Bmatch%5D%3B%20%7D)%3B%20%7D%20w%20%3D%20window.open()%2C%20w.document.open()%2C%20w.document.write('%3C!DOCTYPE%20html%3E%3Chtml%20lang%3D%22ja%22%3E%3Chead%3E%3Ctitle%3EDyn2Md%3C%2Ftitle%3E%3Cstyle%20type%3D%22text%2Fcss%22%3Etextarea%7Bwidth%3A100%25%3Bheight%3A500px%3B%7Dbutton%7Bwidth%3A100%25%3Bheight%3A50px%7D%3C%2Fstyle%3E%3C%2Fhead%3E%3Cbody%3E%3Cbutton%20onclick%3D%22copyToClipboard()%22%3Ecopy%20and%20close%3C%2Fbutton%3E%3Ctextarea%20id%3D%22ta%22%3E'%20%2B%20titletxt%20%2B%20%22%5Cn%5Cn%22%20%2B%20escape_html(outtxt)%20%2B%20'%3C%2Ftextarea%3E%3C%2Fbody%3E%3Cscript%3Efunction%20copyToClipboard()%7Bvar%20ta%3Ddocument.getElementById(%22ta%22)%3Bta.select()%3Bdocument.execCommand(%22Copy%22)%3Bwindow.close()%7D%3C%2Fscript%3E%3C%2Fhtml%3E')%2C%20w.document.close()%3B%20%7D())%3B%7D)()%3B
Discussion