Skip to content
This repository has been archived by the owner on Dec 4, 2017. It is now read-only.

Commit

Permalink
0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jun 13, 2014
0 parents commit dae0c51
Show file tree
Hide file tree
Showing 10 changed files with 1,196 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
.DS_Store
coverage
144 changes: 144 additions & 0 deletions .jscs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
{
"requireCurlyBraces": [
"if",
"else",
"for",
"while",
"do",
"try",
"catch"
],
"requireSpaceAfterKeywords": [
"if",
"else",
"for",
"while",
"do",
"switch",
"return",
"try",
"catch"
],
"requireSpaceBeforeBlockStatements": true,
"requireParenthesesAroundIIFE": true,
"requireSpacesInConditionalExpression": true,
"requireSpacesInFunctionExpression": {
"beforeOpeningCurlyBrace": true
},
"requireSpacesInAnonymousFunctionExpression": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},
"requireSpacesInNamedFunctionExpression": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},
"requireSpacesInFunctionExpression": {
"beforeOpeningCurlyBrace": true
},
"requireMultipleVarDecl": true,
"requireBlocksOnNewline": true,
"disallowPaddingNewlinesInBlocks": true,
"disallowEmptyBlocks": true,
"disallowSpacesInsideObjectBrackets": true,
"disallowSpacesInsideArrayBrackets": true,
"disallowSpacesInsideParentheses": true,
"requireSpacesInsideObjectBrackets": "all",
"disallowDanglingUnderscores": true,
"requireSpaceAfterObjectKeys": true,
"requireCommaBeforeLineBreak": true,
"requireOperatorBeforeLineBreak": [
"?",
"+",
"-",
"/",
"*",
"=",
"==",
"===",
"!=",
"!==",
">",
">=",
"<",
"<="
],
"disallowLeftStickedOperators": [
"?",
"+",
"/",
"*",
"=",
"==",
"===",
"!=",
"!==",
">",
">=",
"<",
"<="
],
"requireRightStickedOperators": ["!"],
"disallowRightStickedOperators": [
"?",
"+",
"/",
"*",
":",
"=",
"==",
"===",
"!=",
"!==",
">",
">=",
"<",
"<="
],
"requireLeftStickedOperators": [","],
"disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"],
"disallowSpaceBeforePostfixUnaryOperators": ["++", "--"],
"requireSpaceBeforeBinaryOperators": [
"+",
"-",
"/",
"*",
"=",
"==",
"===",
"!=",
"!=="
],
"requireSpaceAfterBinaryOperators": [
"+",
"-",
"/",
"*",
"=",
"==",
"===",
"!=",
"!=="
],
"disallowImplicitTypeConversion": ["numeric", "boolean", "binary", "string"],
"requireCamelCaseOrUpperCaseIdentifiers": true,
"disallowKeywords": ["with"],
"disallowMultipleLineStrings": true,
"disallowMultipleLineBreaks": true,
"validateLineBreaks": "LF",
"validateQuoteMarks": "'",
"disallowMixedSpacesAndTabs": true,
"disallowTrailingWhitespace": true,
"disallowKeywordsOnNewLine": ["else"],
"requireLineFeedAtFileEnd": true,
"maximumLineLength": 78,
"requireCapitalizedConstructors": true,
"safeContextKeyword": "self",
"requireDotNotation": true,
"disallowYodaConditions": true,
"validateJSDoc": {
"checkParamNames": true,
"checkRedundantParams": true,
"requireParamTypes": true
}
}
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
coverage
.travis.yml
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
language: "node_js"
before_install:
- "npm update -g npm"
script: "npm run-script test-travis"
node_js:
- "0.10"
- "0.11"
after_script: "npm install coveralls@2.10.0 && cat ./coverage/lcov.info | coveralls"
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(The MIT License)

Copyright (c) 2014 Titus Wormer <tituswormer@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
120 changes: 120 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# retext-content [![Build Status](https://travis-ci.org/wooorm/retext-content.svg?branch=mcontenter)](https://travis-ci.org/wooorm/retext-content) [![Coverage Status](https://img.shields.io/coveralls/wooorm/retext-content.svg)](https://coveralls.io/r/wooorm/retext-content?branch=master)

[![browser support](https://ci.testling.com/wooorm/retext-content.png) ](https://ci.testling.com/wooorm/retext-content)

See [Browser Support](#browser-support) for more information (a.k.a. don’t worry about those grey icons above).

---

Append, prepend, remove, and replace content into/from **[retext](https://github.com/wooorm/retext "Retext")** nodes.

## Installation

NPM:
```sh
$ npm install retext-content
```

Component.js:
```sh
$ component install wooorm/retext-content
```

## Usage

```js
var Retext = require('retext'),
content = require('retext-content');

var root = new Retext()
.use(content)
.parse('simple sentence.');

// Prepend:
rootNode.head.head.prependContent('One ');
root.toString(); // "One simple sentence."

// Append:
rootNode.head.appendContent(' Two sentences.');
root.toString(); // "One simple sentence. Two sentences."

// Replace:
rootNode.replaceContent('One paragraph.\n\nTwo paragraphs.');
root.toString(); // "One paragraph.\n\nTwo paragraphs."

// Remove:
rootNode.tail.removeContent();
root.toString(); // "One paragraph.\n\n"
```

## API

#### TextOM.Parent#prependContent(value)

```js
var Retext = require('retext'),
content = require('content'),
rootNode = new Retext().use(content).parse('simple sentence.');

// Prepend into the first sentence of the first paragraph:
rootNode.head.head.prependContent('A document including a ')
rootNode.toString(); // 'A document including a simple sentence.'
```

Inserts the parsed value at the beginning of the parent.

- `value` (Non-empty `String`): The to-parse and prepend inside content.

#### TextOM.Parent#appendContent(value)

```js
var Retext = require('retext'),
content = require('content'),
rootNode = new Retext().use(content).parse('A document');

// Append into the first sentence of the first paragraph:
rootNode.head.head.appendContent(' including a simple sentence');
rootNode.toString(); // 'A document including a simple sentence.'
```

Inserts the parsed value at the end of the parent.

- `value` (Non-empty `String`): The to-parse and append inside content.

#### TextOM.Parent#removeContent()

```js
var Retext = require('retext'),
content = require('content'),
rootNode = new Retext().use(content).parse('A sentence. Another sentence.');

// Remove the content of the first sentence of the first paragraph:
rootNode.head.head.removeContent();
rootNode.toString(); // ' Another sentence.'
```

Removes the current content of the parent.

#### TextOM.Parent#replaceContent(value?)

```js
var Retext = require('retext'),
content = require('content'),
rootNode = new Retext().use(content).parse('A sentence.');

// Replace the content of the first paragraph:
rootNode.head.replaceContent('One sentence. Two sentences.');
rootNode.toString(); // 'One sentence. Two sentences.'
```

Removes the current content of the parent, and replaces it with the parsed value.

- `value` (`String`): The to-parse and insert inside content.


## Browser Support
Pretty much every browser (available through browserstack) runs all retext-content unit tests.

## License

MIT
14 changes: 14 additions & 0 deletions component.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "retext-content",
"repository": "wooorm/retext-content",
"description": "Append, prepend, remove, and replace content into/from Retext nodes",
"version": "0.0.1",
"keywords": [
"retext",
"content"
],
"scripts" : [
"index.js"
],
"license": "MIT"
}
Loading

0 comments on commit dae0c51

Please sign in to comment.