Skip to content

Instantly share code, notes, and snippets.

@konn
Last active January 6, 2018 12:12
Show Gist options
  • Select an option

  • Save konn/ad56ff8cc89f6e39f6eb to your computer and use it in GitHub Desktop.

Select an option

Save konn/ad56ff8cc89f6e39f6eb to your computer and use it in GitHub Desktop.
iText Pro ルビ・圏点→InDesign 変換スクリプト
var app = Application("Adobe InDesign CS5"),
doc = app.activeDocument,
style = doc.styles;
doc.hyperlinks()
.forEach(function(ref){
try {
if (dest = ref.destination.destinationURL()) {
var comp = dest.match(/\/RubyText:(.+?)$/i)
horz = dest.match(/\/horzInVert:$/i)
target = ref.source.sourceText()
if (comp && (c = comp[1])) {
var ruby = decodeURIComponent(c);
var attr, val;
switch (ruby) {
case "◉":
console.log("圏点:蛇の目");
attr = 'kentenKind';
val = 'kenten fisheye';
break;
case "◎":
console.log("圏点:二重丸");
attr = 'kentenKind';
val = 'kenten bullseye';
break;
case "﹅":
console.log("圏点:黒ゴマ");
attr = 'kentenKind';
val = 'kenten sesame dot';
break;
case "﹆":
console.log("圏点:白ゴマ");
attr = 'kentenKind';
val = 'kenten white sesame dot';
break;
case "▲":
console.log("圏点:黒三角");
attr = 'kentenKind';
val = 'kenten black triangle';
break;
case "△":
console.log("圏点:白三角");
attr = 'kentenKind';
val = 'kenten white triangle';
break;
case "●":
console.log("圏点:黒丸");
attr = 'kentenKind';
val = 'kenten small black circle';
break;
case "○":
console.log("圏点:白丸");
attr = 'kentenKind';
val = 'kenten small white circle';
break;
default:
console.log("ルビ:", ruby);
target.rubyType = 'group ruby';
target.rubyFlag = true;
attr = 'rubyString';
val = ruby;
}
target[attr] = val;
ref.delete();
} else if ( horz ) {
console.log("縦中横");
target.tatechuyoko = true;
ref.delete();
}
}
} catch(_e) {
console.log("*** " + _e);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment