Last active
August 13, 2018 11:26
-
-
Save k163377/59110c5007c7e1f15d2c18969fbb19e7 to your computer and use it in GitHub Desktop.
https://raw.githubusercontent.com/hiroppy/github-language-color-themes/master/languages.json ←をAndroidの色xmlに変換する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedReader | |
import java.io.FileNotFoundException | |
import java.io.FileReader | |
val prefix: String = "<color name=" | |
val middle: String = ">" | |
val suffix: String = "</color>" | |
fun main(args:Array<String>) { | |
try{ | |
val br = BufferedReader(FileReader("C:\\Users\\wrongwrong\\IdeaProjects\\MakeLangColorXML\\src\\languages.json")) | |
var temp: String? = br.readLine() | |
var color: String | |
while (temp != null){ | |
if(temp.contains("\": {")){ | |
//言語名、xmlでは使えない文字は_で置換 | |
color = prefix + | |
temp.split(':')[0] | |
.substring(2) | |
.replace(' ', '_') | |
.replace('+', '_') | |
.replace('#', '_') | |
.replace('-', '_') | |
.replace('\'', '_') + | |
middle | |
temp = br.readLine() | |
while(true){ | |
if(temp!!.contains("color")) { | |
color += temp.split(": \"")[1].split("\",")[0].split('\"')[0] + suffix | |
println(color) | |
break | |
}else if(temp == " },") break | |
temp = br.readLine() | |
} | |
} | |
temp = br.readLine() | |
} | |
}catch (e: FileNotFoundException){ | |
println(e) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
色入ってない場合があって死ぬので修正