forked from jshingler/TOS-and-Thinkscript-Snippet-Collection
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathj.groovy
More file actions
executable file
·26 lines (24 loc) · 836 Bytes
/
Copy pathj.groovy
File metadata and controls
executable file
·26 lines (24 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//sed -e "s/- .*-//" j.txt | sed -e "s/\.\..*$//" | sed -e "s/ /_/g" | sed -e "s/\(.*\)/[xxx](#\1)/"
// groovy
File file1 = new File('j.txt')
file1.eachLine { line ->
//println ">${line}<"
if (line.startsWith("- ") && !line.startsWith("- NEXT")) {
l1 = line.replace("- ","")
l2 = line.toUpperCase().split(/\./)[0].trim()
//println "l2>${l2.split(/\-/).size()} <l2"
if (l2.split(/\-/).size() > 2) {
l3 = l2.split(/\-/)[2]
.replaceAll(" ","_")
.replaceAll("'","")
.replaceAll(",","")
.replaceAll("\\(","")
.replaceAll("\\)","")
.replaceAll("&","AND")
println "- [${l1}](#$l3)"
println "<a name=\"${l3}\"> </a>"
}
} else {
println line
}
}