Skip to content

Instantly share code, notes, and snippets.

@chriseidhof
Created July 31, 2015 08:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chriseidhof/da6647b3b2ca2e8df2f2 to your computer and use it in GitHub Desktop.
Save chriseidhof/da6647b3b2ca2e8df2f2 to your computer and use it in GitHub Desktop.
#!/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