playgroundbooks / playgroundbook

Tool for Swift Playground books
https://ashfurrow.com/blog/swift-playground-books/
MIT License
260 stars 17 forks source link

Strip newlines/whitespace from code #20

Closed ashfurrow closed 8 years ago

ashfurrow commented 8 years ago

Code blocks like this come out with extra whitespace around them:

//// Page whatever

doSomething()

/*:
 Text
*/

Is translated to:


doSomething()

With extra newlines at the bottom.

A PR fixing this issue should strip whitespace from the beginning/end of a page's code.

ashfurrow commented 8 years ago

Looks like Swift Playgrounds automatically strips whitespace from the beginning/end of a file, which is handy.

ashfurrow commented 8 years ago

So basically we'd need to strip the page contents of any newlines that exist adjacent to markdown blocks. Examples:


//:

/*:
 */

Should be doable with regexes, needs to be well-tested.