Created
July 31, 2015 08:35
-
-
Save chriseidhof/da6647b3b2ca2e8df2f2 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env xcrun swift -F Rome | |
import Foundation | |
import CommonMark | |
import LiterateSwift | |
func stripPrelude(var blocks: [Block]) -> [Block] { | |
guard blocks.count > 0 else { return blocks } | |
guard case let Block.Header(text, _) = blocks[0] where text.count == 1 else { | |
return blocks | |
} | |
guard case InlineElement.Text(text: "Prelude") = text[0] else { | |
return blocks | |
} | |
blocks.dropFirst() | |
for el in blocks { | |
if case Block.CodeBlock(_, _) = el { | |
blocks.removeAtIndex(0) | |
} else { | |
break | |
} | |
} | |
return blocks | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment