File tree Expand file tree Collapse file tree 1 file changed +16
-13
lines changed
Expand file tree Collapse file tree 1 file changed +16
-13
lines changed Original file line number Diff line number Diff line change 33/*
44 OVERVIEW: Convert Xcode Playground to markdown
55
6- USAGE: cat Playgrounds/Example .playground/Contents.swift | ./Scripts/markdown.swift
6+ USAGE: cat Playgrounds/README .playground/Contents.swift | ./Scripts/markdown.swift
77 */
88
99enum TextBlock {
@@ -13,20 +13,23 @@ enum TextBlock {
1313var block = TextBlock . unknown
1414
1515while let line = readLine ( ) {
16- if line . hasPrefix ( " /*") {
17- if block == .code {
18- print("```")
19- }
16+ switch block {
17+ case . unknown where line . isEmpty :
18+ break
19+ case . unknown where line . hasPrefix ( " /* " ) :
2020 block = . comment
21- } else if line.hasSuffix("*/" ) {
22- print ( " ```swift " )
21+ case . unknown:
2322 block = . code
24- } else if block == . comment {
25- print ( line. drop ( while: \. isWhitespace) )
26- } else {
23+ print ( " ```swift " )
2724 print ( line)
25+ case . code where line. hasPrefix ( " /*"):
26+ block = .comment
27+ print("```")
28+ case .code:
29+ print(line)
30+ case .comment where line.hasSuffix("*/" ) :
31+ block = . unknown
32+ case . comment:
33+ print ( line. drop ( while: \. isWhitespace) )
2834 }
2935}
30- if block == . code {
31- print ( " ``` " )
32- }
You can’t perform that action at this time.
0 commit comments