Skip to content

Commit

Permalink
Merge pull request jxson#46 from taras/patch-2
Browse files Browse the repository at this point in the history
Added code highlighting to README
  • Loading branch information
jxson authored Nov 18, 2016
2 parents d11acb9 + b9bd8f1 commit 0eb6559
Showing 1 changed file with 31 additions and 21 deletions.
52 changes: 31 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,43 +25,51 @@ With [npm][npm] do:

So you have a file `example.md`:

---
title: Just hack'n
description: Nothing to see here
---
```yaml
---
title: Just hack'n
description: Nothing to see here
---

This is some text about some stuff that happened sometime ago
This is some text about some stuff that happened sometime ago
```

**NOTE:** As of `[email protected]` valid front matter is considered to have
the starting separator on the first line.

Then you can do this:

var fs = require('fs')
, fm = require('front-matter')
```javascript
var fs = require('fs')
, fm = require('front-matter')

fs.readFile('./example.md', 'utf8', function(err, data){
if (err) throw err
fs.readFile('./example.md', 'utf8', function(err, data){
if (err) throw err

var content = fm(data)
var content = fm(data)

console.log(content)
})
console.log(content)
})
```

And end up with an object like this:

{
attributes: {
title: 'Just hack\'n',
description: 'Nothing to see here'
},
body: '\nThis is some text about some stuff that happened sometime ago',
frontmatter: 'title: Just hack\'n\ndescription: Nothing to see here'
}
```javascript
{
attributes: {
title: 'Just hack\'n',
description: 'Nothing to see here'
},
body: '\nThis is some text about some stuff that happened sometime ago',
frontmatter: 'title: Just hack\'n\ndescription: Nothing to see here'
}
```

# Methods

var fm = require('front-matter')
```javascript
var fm = require('front-matter')
```

## fm(string)

Expand All @@ -77,7 +85,9 @@ Check if a string contains a front matter header of "---" or "= yaml =". Primari

Returns `true` or `false`

```javascript
fm.test(string) #=> true || false
```

# Contributing

Expand Down

0 comments on commit 0eb6559

Please sign in to comment.