Skip to content

Commit

Permalink
Deprecate 'bare'.
Browse files Browse the repository at this point in the history
  • Loading branch information
rstacruz committed Feb 24, 2014
1 parent 5204819 commit d0d968f
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 52 deletions.
21 changes: 10 additions & 11 deletions Todo.task
Expand Up @@ -12,23 +12,22 @@ For project:
- Wrapping
- `.sg-text` - Wrap text elements of an .sg-block (!) @done(2014-02-24)
- `.sg-example` - rename code-block to this @done(2014-02-24)
- `.sg-block` should include `.sg-with-example`
- Tags
- `@ example padded`
- `@ example .light` (classnames) @done(2014-02-24)
- `@ example full`
- `@ example` @done(2014-02-24)
- `@ font="100 proxima nova"`
- `@ colors`
- classes should apply to .sg-canvas not .sg-example
- `@example` @done(2014-02-24)
- `@example.light` (classnames) @done(2014-02-24)
- `@example.padded` (bordered) @done(2014-02-24)
- `@example.full`
- `@specimen weight=100 font="proxima nova" headline=1.5em paragraph=1em`
- `@colors`
- Trimming
- trim (sg:snip) to ellipsis
- remove (sg:isolate)
- trim to ellipsis (sg:snip)
- remove current element (sg:omit)
- Refactor
- Remove bare:true in favor of head:false
- Bootstrapping
- styledown --css @done(2014-02-24)
- styledown --new

Later features:
- Add .sg-block-with-example
- jade-less mode @done(2014-02-24)
- `@input @result` (for sass examples)
12 changes: 2 additions & 10 deletions index.js
Expand Up @@ -27,11 +27,6 @@ function Styledown (src, options) {
}

Styledown.defaults = {
/**
* Disable template if true
*/
bare: false,

/**
* HTML template
*/
Expand All @@ -50,10 +45,7 @@ Styledown.defaults = {
/**
* Things to put into `head`
*/
head: [
'<link rel="stylesheet" href="styledown.css" type="text/css">',
'<script src="styledown.js"></script>'
].join("\n"),
head: false,

body: "<div sg-content></div>",

Expand Down Expand Up @@ -85,7 +77,7 @@ Styledown.prototype = {
toHTML: function() {
var html = this.$.html();

if (!this.options.bare) {
if (this.options.head !== false) {
// Unpack template
var $ = Cheerio.load(this.options.template);
$('body').append(htmlize(this.options.body));
Expand Down
8 changes: 4 additions & 4 deletions test/body_template_test.coffee
@@ -1,11 +1,11 @@
require './setup'

describe 'options.body', ->
describe 'Body template test', ->
beforeEach ->
@load '''
## hello
'''
''', head: ''

it 'wrap in div', ->
expect(@$('body > div')).have.length 1
expect(@$('body > div > section')).have.length 1
expect(@$).have.selector 'body > div'
expect(@$).have.selector 'body > div > section'
2 changes: 1 addition & 1 deletion test/default_css_test.coffee
@@ -1,6 +1,6 @@
require './setup'

describe 'Default CSS', ->
xdescribe 'Default CSS', ->
describe 'on', ->
beforeEach ->
@load "### hi"
Expand Down
2 changes: 1 addition & 1 deletion test/express_test.coffee
Expand Up @@ -6,7 +6,7 @@ describe 'Express', ->
Expect = chai.expect
Express = require('express')

beforeEach ->
before ->
@app = Express()
@app.use StyledownHandler
root: __dirname
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/sample.md
@@ -1,3 +1,8 @@
# Sample

Hello there from sample.md

# Styleguide options

### head
<link rel='stylesheet' href='styledown.css'>
2 changes: 2 additions & 0 deletions test/jade_template_test.coffee
Expand Up @@ -22,6 +22,8 @@ describe 'Jade Templates', ->
hello
# Styleguide options
## head
link
## body
#hello(sg-content)
'''
Expand Down
58 changes: 37 additions & 21 deletions test/markdown_test.coffee
@@ -1,24 +1,40 @@
require './setup'

describe 'basic markdown', ->
beforeEach ->
@load '''
# Hello
there
'''

it 'text', ->
expect(@$("h1").text()).eql 'Hello'
expect(@$("p").text()).eql 'there'

it 'classnames', ->
expect(@$).have.selector 'h1.sg'
expect(@$).have.selector 'p.sg'

it 'html template', ->
expect(@html).match /doctype html/
expect(@html).match /body/
expect(@html).match /head/
expect(@$).have.selector 'meta[charset="utf-8"]'
expect(@$("title").text().length).gt 0
describe 'Markdown', ->
describe 'with template', ->
beforeEach ->
@load '''
# Hello
there
''', head: ''

it 'text', ->
expect(@$("h1").text()).eql 'Hello'
expect(@$("p").text()).eql 'there'

it 'classnames', ->
expect(@$).have.selector 'h1.sg'
expect(@$).have.selector 'p.sg'

it 'html template', ->
expect(@html).match /doctype html/
expect(@html).match /body/
expect(@html).match /head/
expect(@$).have.selector 'meta[charset="utf-8"]'
expect(@$("title").text().length).gt 0

describe 'bare', ->
beforeEach ->
@load '''
# Hello
there
'''

it 'text', ->
expect(@$("h1").text()).eql 'Hello'
expect(@$("p").text()).eql 'there'

it 'classnames', ->
expect(@$).have.selector 'h1.sg'
expect(@$).have.selector 'p.sg'

4 changes: 2 additions & 2 deletions test/prefix_test.coffee
Expand Up @@ -3,7 +3,7 @@ require './setup'
describe 'Prefix', ->
describe 'in options', ->
beforeEach ->
@load "## Hello\n### world\nthere", prefix: "styleguide"
@load "## Hello\n### world\nthere", prefix: "styleguide", head: ''

it 'classnames in stuff', ->
expect(@$("h2").is('.styleguide')).be.true
Expand All @@ -27,7 +27,7 @@ describe 'Prefix', ->

describe 'inline options', ->
beforeEach ->
@load "## Hello\n###world\nthere\n\n# Styleguide options\n\n* prefix: styleguide"
@load "## Hello\n###world\nthere\n\n# Styleguide options\n\n* prefix: styleguide", head: ''

it 'classnames in stuff', ->
expect(@$("h2").is('.styleguide')).be.true
Expand Down
6 changes: 4 additions & 2 deletions test/pretty_print_test.coffee
Expand Up @@ -3,7 +3,7 @@ require './setup'
describe 'Pretty Print', ->
describe 'default', ->
beforeEach ->
@load "### Hello\n\n @example\n div"
@load "### Hello\n\n @example\n div", head: ''

it 'should work', ->

Expand All @@ -21,7 +21,7 @@ describe 'Pretty Print', ->

describe 'custom indentSize', ->
beforeEach ->
@load "### Hello\n\n @example\n div", indentSize: 4
@load "### Hello\n\n @example\n div", indentSize: 4, head: ''

it 'should work', ->

Expand All @@ -36,3 +36,5 @@ describe 'Pretty Print', ->

it 'indent .sg-canvas', ->
expect(@html).match /\n {20}<div class="sg-canvas/

xdescribe 'custom indentSize, no head', ->

0 comments on commit d0d968f

Please sign in to comment.