0.1.0 • Published 10 years ago
go-type v0.1.0
Go-type
Go-type turns Go diagrams in Sensei's Library Format into SVG. In other words, it turns this:
$$Bc A joseki variation
$$ ------------------
$$ | . . . . . . . . .
$$ | . . . . . . . . .
$$ | . . 7 3 X d . . .
$$ | . . O 1 O 6 . . .
$$ | . . 4 2 5 c . . .
$$ | . . 8 X a . . . .
$$ | . . . b . . . . .
$$ | . . . . . . . . .
$$ | . . . . . . . . .
...into this:
A joseki variation
Usage
In the browser
Include D3 and go-type (download):
<link rel="stylesheet" href="go-type.css"> <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> <script src="go-type.js"></script>
Put Go diagrams on the page:
<div class="slf-board"><pre> $$Bc A joseki variation $$ ------------------ $$ | . . . . . . . . . $$ | . . . . . . . . . $$ | . . 7 3 X d . . . $$ | . . O 1 O 6 . . . $$ | . . 4 2 5 c . . . $$ | . . 8 X a . . . . $$ | . . . b . . . . . $$ | . . . . . . . . . $$ | . . . . . . . . . </pre></div> <script> d3.selectAll('.slf-board').each(goType.rewrite); </script>
In Node.js
Add
go-type
as a dependency in your Node.js project withnpm install go-type --save
Use
goType.stream()
in a pipeline to transform Go diagrams into SVG. You can mix Go diagrams with other text — diagrams become SVG while other text passes through.var goType = require('go-type'), fs = require('fs'); fs.createReadStream('./in.html') .pipe(goType.stream()) .pipe(fs.createWriteStream('./out.html'));
Include go-type CSS in the resulting HTML (download):
<link rel="stylesheet" href="go-type.css">
0.1.0
10 years ago