Skip to content

Commit

Permalink
Require problems to be written in Markdown, and use msee to render it.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjb committed Oct 27, 2013
1 parent d819e43 commit dc7e62e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Where the menu items correspond to lower-case, punctuation-free directories in a

Each subdirectory in the *problems/* directory should contain the following files:

* **problem.txt** - a description of the problem. You can use [colors-tmpl](https://github.com/rvagg/colors-tmpl) formatting for colouring and you may also use the string `{appname}` to substitute in the name you provided to `Workshopper()` and `{rootdir}` to substitute for the absolute path of where your application has been installed on the users' system.
* **problem.txt** - a description of the problem, in [GitHub Flavored Markdown](https://help.github.com/articles/github-flavored-markdown). You should use fenced code blocks for example code. You can use [colors-tmpl](https://github.com/rvagg/colors-tmpl) formatting for colouring and you may also use the string `{appname}` to substitute in the name you provided to `Workshopper()` and `{rootdir}` to substitute for the absolute path of where your application has been installed on the users' system.
* **setup.js** - a module that sets up the test environment with any fixtures required and can verify solutions. More on this below.
* **solution.js** - the "official" solution to the problem. You can have multiple files in your solution, they filenames just need to be prefixed with 'solution' and end with '.js' and they will all be shown together as the official solution.

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"terminal-menu": "~0.1.0",
"optimist": "~0.6.0",
"pygmentize-bundled": "~2.1.0",
"xtend": "~2.1.1"
"xtend": "~2.1.1",
"msee": "~0.1.0-alpha.3"
}
}
4 changes: 4 additions & 0 deletions print-text.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const fs = require('fs')
, path = require('path')
, colorsTmpl = require('colors-tmpl')
, msee = require('msee')

function printText (name, appDir, file, callback) {
var variables = {
Expand All @@ -21,6 +22,9 @@ function printText (name, appDir, file, callback) {
contents = contents.replace(/\{rootdir:([^}]+)\}/gi, function (match, subpath) {
return path.join(appDir, subpath)
})
// convert Markdown to ANSI
contents = msee.parse(contents)

console.log(contents)
callback && callback()
})
Expand Down
13 changes: 4 additions & 9 deletions workshopper.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const argv = require('optimist').argv
, mkdirp = require('mkdirp')
, map = require('map-async')
, pygmentize = require('pygmentize-bundled')
, msee = require('msee')

const showMenu = require('./menu')
, verify = require('./verify')
Expand Down Expand Up @@ -267,15 +268,9 @@ function onpass (setup, dir, current) {
map(
solutions
, function (file, i, callback) {
pygmentize(
{ lang: 'js', format: 'terminal256' }
, file.content
, function (err, content) {
if (!err)
file.content = content.toString()
callback(null, file)
}
)
// code fencing is necessary for msee to render the solution as code
file.content = msee.parse("```js\n" + file.content + "\n```")
callback(null, file)
}
, function (err, solutions) {
if (err)
Expand Down

0 comments on commit dc7e62e

Please sign in to comment.