Skip to content
This repository was archived by the owner on Aug 2, 2020. It is now read-only.

Commit 561c3ed

Browse files
committed
Initial commit.
0 parents  commit 561c3ed

File tree

14 files changed

+289
-0
lines changed

14 files changed

+289
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

.jslintrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"browser": true,
3+
"predef": [
4+
"define",
5+
"module"
6+
]
7+
}

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
language: node_js
2+
node_js:
3+
- "0.10"
4+
before_install:
5+
- npm install -g grunt-cli

Gruntfile.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
module.exports = function (grunt) {
2+
3+
'use strict';
4+
5+
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
6+
7+
grunt.initConfig({
8+
9+
pkg: grunt.file.readJSON('package.json'),
10+
11+
jslint: {
12+
13+
client: {
14+
src: ['de-pre.js'],
15+
directives: {
16+
browser: true,
17+
globals: {
18+
'define': true,
19+
'module': true
20+
}
21+
}
22+
}
23+
24+
},
25+
26+
uglify: {
27+
28+
my_target: {
29+
options: {
30+
mangle: true,
31+
report: 'gzip',
32+
banner: '/*!\n * <%= pkg.name %> v<%= pkg.version %> <%= grunt.template.today("isoDateTime") %>\n * https://github.com/neogeek/de-pre.js\n * \n * Copyright (c) <%= grunt.template.today("yyyy") %> Scott Doxey\n * Released under the MIT license.\n */\n'
33+
},
34+
files: {
35+
'de-pre.min.js': ['de-pre.js']
36+
}
37+
}
38+
39+
},
40+
41+
jasmine: {
42+
test: {
43+
src: 'de-pre.min.js',
44+
options: {
45+
specs: 'tests/*.js',
46+
vendor: [
47+
'http://cdn.jsdelivr.net/jquery/2.1.1/jquery.min.js'
48+
]
49+
}
50+
}
51+
},
52+
53+
watch: {
54+
55+
default: {
56+
files: ['de-pre.js'],
57+
tasks: ['jslint', 'uglify']
58+
}
59+
60+
}
61+
62+
});
63+
64+
grunt.registerTask('default', [ 'jslint', 'uglify' ]);
65+
grunt.registerTask('test', [ 'jasmine' ]);
66+
67+
};

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 Scott Doxey
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[![](https://api.travis-ci.org/neogeek/de-pre.js.svg)](https://travis-ci.org/neogeek/de-pre.js) [![](https://david-dm.org/neogeek/de-pre.js/dev-status.svg)](https://david-dm.org/neogeek/de-pre.js/#info=devDependencies)
2+
3+
#de-pre.js
4+
5+
> Removes excess indentation from the contents of pre tags, allowing proper indentation in HTML.
6+
7+
##Usage
8+
9+
```javascript
10+
depre('pre');
11+
```

bower.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "de-pre.js",
3+
"description": "Removes excess indentation from the contents of pre tags, allowing proper indentation in HTML.",
4+
"version": "0.0.1",
5+
"main": "de-pre.js",
6+
"license": "MIT",
7+
"ignore": [
8+
],
9+
"keywords": [
10+
"pre",
11+
"html",
12+
"whitespace"
13+
],
14+
"authors": [
15+
{
16+
"name": "Scott Doxey",
17+
"email": "[email protected]",
18+
"homepage": "http://scottdoxey.com/"
19+
}
20+
],
21+
"repository": {
22+
"type": "git",
23+
"url": "git://github.com/neogeek/de-pre.js.git"
24+
},
25+
"private": true
26+
}

de-pre.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*!
2+
* de-pre.js
3+
* https://github.com/neogeek/de-pre.js
4+
*
5+
* Copyright (c) 2014 Scott Doxey
6+
* Released under the MIT license.
7+
*/
8+
9+
(function (root, factory) {
10+
11+
'use strict';
12+
13+
if (typeof define === 'function' && define.amd !== undefined) {
14+
15+
define([], factory);
16+
17+
} else {
18+
19+
root.depre = factory;
20+
21+
}
22+
23+
}(this, function (tag) {
24+
25+
'use strict';
26+
27+
Array.prototype.slice.call(document.querySelectorAll(tag)).forEach(function (obj) {
28+
29+
var indent = obj.previousSibling.nodeValue.match(/([ \t]*)$/);
30+
31+
obj.innerText = obj.innerText.replace(new RegExp('(^|\n)' + indent[1], 'g'), '$1');
32+
33+
});
34+
35+
}));

de-pre.min.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*!
2+
* de-pre.js v0.0.1 2014-08-12T21:42:02
3+
* https://github.com/neogeek/de-pre.js
4+
*
5+
* Copyright (c) 2014 Scott Doxey
6+
* Released under the MIT license.
7+
*/
8+
!function(a,b){"use strict";"function"==typeof define&&void 0!==define.amd?define([],b):a.depre=b}(this,function(a){"use strict";Array.prototype.slice.call(document.querySelectorAll(a)).forEach(function(a){var b=a.previousSibling.nodeValue.match(/([ \t]*)$/);a.innerText=a.innerText.replace(new RegExp("(^|\n)"+b[1],"g"),"$1")})});

package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "de-pre.js",
3+
"description": "Removes excess indentation from the contents of pre tags, allowing proper indentation in HTML.",
4+
"version": "0.0.1",
5+
"main": "de-pre.js",
6+
"devDependencies": {
7+
"grunt": "0.4.5",
8+
"grunt-contrib-watch": "0.6.1",
9+
"grunt-contrib-jasmine": "0.7.0",
10+
"grunt-contrib-uglify": "0.5.1",
11+
"grunt-jslint": "1.1.12",
12+
"grunt-notify": "0.3.1",
13+
"matchdep": "0.3.0"
14+
},
15+
"scripts": {
16+
"test": "grunt test"
17+
}
18+
}

0 commit comments

Comments
 (0)