Vitaly Puzrin
10 years ago
commit
c8be724b3f
16 changed files with 1737 additions and 0 deletions
@ -0,0 +1,12 @@ |
|||
# Cross-editor coding style settings. |
|||
# See http://editorconfig.org/ for details. |
|||
|
|||
root = true |
|||
|
|||
[*] |
|||
charset = utf-8 |
|||
indent_style = space |
|||
indent_size = 2 |
|||
end_of_line = lf |
|||
trim_trailing_whitespace = true |
|||
insert_final_newline = true |
@ -0,0 +1,2 @@ |
|||
/node_modules/ |
|||
|
@ -0,0 +1,5 @@ |
|||
.git/ |
|||
benchmark/implementations/ |
|||
node_modules/ |
|||
demo/ |
|||
dist/ |
@ -0,0 +1,82 @@ |
|||
{ |
|||
// Enforcing Options ///////////////////////////////////////////////////////// |
|||
|
|||
"bitwise" : false, // Prohibit bitwise operators (&, |, ^, etc.). |
|||
// false - specific for js-yaml |
|||
|
|||
"camelcase" : false, // Require variable names to be camelCase style or UPPER_CASE |
|||
"curly" : true, // Require {} for every new block or scope. |
|||
"eqeqeq" : true, // Require triple equals i.e. `===`. |
|||
"forin" : false, // Tolerate `for in` loops without `hasOwnPrototype`. |
|||
"immed" : true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );` |
|||
"indent" : 2, // This option enforces specific tab width for your code |
|||
"latedef" : false, // Prohibit hariable use before definition. |
|||
"newcap" : true, // Require capitalization of all constructor functions e.g. `new F()`. |
|||
"noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`. |
|||
"noempty" : true, // Prohibit use of empty blocks. |
|||
"nonew" : true, // Prohibit use of constructors for side-effects. |
|||
"plusplus" : false, // Prohibit use of `++` & `--`. |
|||
"quotmark" : false, // Enforces the consistency of quotation marks used throughout your code. |
|||
"regexp" : false, // Prohibit `.` and `[^...]` in regular expressions. |
|||
"undef" : true, // Require all non-global variables be declared before they are used. |
|||
"unused" : false, // This option warns when you define and never use your variables. |
|||
"strict" : true, // Require `use strict` pragma in every file. |
|||
"trailing" : true, // Prohibit trailing whitespaces. |
|||
"maxparams" : 5, // Enforce max number of formal parameters allowed per function |
|||
"maxdepth" : 5, // Enforce max depth of nested blocks |
|||
"maxstatements" : false, // Enforce max amount of statements per function |
|||
"maxcomplexity" : false, // Enforce cyclomatic complexity level |
|||
|
|||
// Relaxing Options ////////////////////////////////////////////////////////// |
|||
|
|||
"asi" : false, // Tolerate Automatic Semicolon Insertion (no semicolons). |
|||
"boss" : false, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments. |
|||
"debug" : false, // Allow debugger statements e.g. browser breakpoints. |
|||
"eqnull" : false, // Tolerate use of `== null`. |
|||
//"es5" : true, // Allow ECMAScript 5 syntax. |
|||
"esnext" : false, // Allow ES.next specific features such as const and let |
|||
"evil" : false, // Tolerate use of `eval`. |
|||
"expr" : false, // Tolerate `ExpressionStatement` as Programs. |
|||
"funcscope" : false, // Tolerate declaring variables inside of control structures while accessing them later |
|||
"globalstrict" : true, // Allow global "use strict" (also enables 'strict'). |
|||
"iterator" : false, // Allow usage of __iterator__ property. |
|||
"lastsemic" : false, // Tolerate semicolon omited for the last statement. |
|||
"laxbreak" : false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons. |
|||
"laxcomma" : true, // This option suppresses warnings about comma-first coding style |
|||
"loopfunc" : false, // Allow functions to be defined within loops. |
|||
"multistr" : false, // Tolerate multi-line strings. |
|||
"onecase" : false, // Tolerate swithes with only one case. |
|||
"proto" : false, // Allow usage of __proto__ property. |
|||
"regexdash" : false, // Tolerate unescaped last dash i.e. `[-...]`. |
|||
"scripturl" : true, // Tolerate script-targeted URLs. |
|||
"smarttabs" : false, // Allow mixed tabs and spaces when the latter are used for alignmnent only. |
|||
"shadow" : false, // Allows re-define variables later in code e.g. `var x=1; x=2;`. |
|||
"sub" : true, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`. |
|||
"supernew" : true, // Tolerate `new function () { ... };` and `new Object;`. |
|||
|
|||
// Environments ////////////////////////////////////////////////////////////// |
|||
|
|||
"browser" : false, // Defines globals exposed by modern browsers |
|||
"couch" : false, // Defines globals exposed by CouchDB |
|||
"devel" : false, // Allow developments statements e.g. `console.log();`. |
|||
"dojo" : false, // Defines globals exposed by the Dojo Toolkit |
|||
"jquery" : false, // Defines globals exposed by the jQuery |
|||
"mootools" : false, // Defines globals exposed by the MooTools |
|||
"node" : true, // Defines globals exposed when running under Node.JS |
|||
"nonstandard" : false, // Defines non-standard but widely adopted globals such as escape and unescape |
|||
"prototypejs" : false, // Defines globals exposed by the Prototype |
|||
"rhino" : false, // Defines globals exposed when running under Rhino |
|||
"worker" : false, // Defines globals exposed when running Web Worker |
|||
"wsh" : false, // Defines globals exposed when running under WSH |
|||
|
|||
// Legacy //////////////////////////////////////////////////////////////////// |
|||
|
|||
"nomen" : false, // Prohibit use of initial or trailing underbars in names. |
|||
"onevar" : false, // Allow only one `var` statement per function. |
|||
"passfail" : false, // Stop on first error. |
|||
"white" : false, // Check against strict whitespace and indentation rules. |
|||
|
|||
// Other ///////////////////////////////////////////////////////////////////// |
|||
|
|||
"maxerr" : 100 // Maximum error before stopping. |
|||
} |
@ -0,0 +1,6 @@ |
|||
/benchmark/ |
|||
/demo/ |
|||
/test/ |
|||
/.* |
|||
/Makefile |
|||
|
@ -0,0 +1,4 @@ |
|||
language: node_js |
|||
node_js: |
|||
- '0.10' |
|||
script: make test |
@ -0,0 +1,87 @@ |
|||
PATH := ./node_modules/.bin:${PATH} |
|||
|
|||
NPM_PACKAGE := $(shell node -e 'process.stdout.write(require("./package.json").name)') |
|||
NPM_VERSION := $(shell node -e 'process.stdout.write(require("./package.json").version)') |
|||
|
|||
TMP_PATH := /tmp/${NPM_PACKAGE}-$(shell date +%s) |
|||
|
|||
REMOTE_NAME ?= origin |
|||
REMOTE_REPO ?= $(shell git config --get remote.${REMOTE_NAME}.url) |
|||
|
|||
CURR_HEAD := $(firstword $(shell git show-ref --hash HEAD | cut -b -6) master) |
|||
GITHUB_PROJ := https://github.com//jonschlinkert/${NPM_PACKAGE} |
|||
|
|||
|
|||
help: |
|||
echo "make help - Print this help" |
|||
echo "make lint - Lint sources with JSHint" |
|||
echo "make test - Lint sources and run all tests" |
|||
echo "make browserify - Build browserified version" |
|||
echo "make dev-deps - Install developer dependencies" |
|||
echo "make gh-pages - Build and push API docs into gh-pages branch" |
|||
echo "make publish - Set new version tag and publish npm package" |
|||
echo "make todo - Find and list all TODOs" |
|||
|
|||
|
|||
lint: |
|||
jshint . --show-non-errors |
|||
|
|||
|
|||
test: lint |
|||
# NODE_ENV=test mocha -R spec |
|||
|
|||
|
|||
gh-pages: |
|||
@if test -z ${REMOTE_REPO} ; then \
|
|||
echo 'Remote repo URL not found' >&2 ; \
|
|||
exit 128 ; \
|
|||
fi |
|||
mkdir ${TMP_PATH} |
|||
cp -r demo/* ${TMP_PATH} |
|||
touch ${TMP_PATH}/.nojekyll |
|||
cd ${TMP_PATH} && \
|
|||
git init && \
|
|||
git add . && \
|
|||
git commit -q -m 'Updated browserified demo' |
|||
cd ${TMP_PATH} && \
|
|||
git remote add remote ${REMOTE_REPO} && \
|
|||
git push --force remote +master:gh-pages |
|||
rm -rf ${TMP_PATH} |
|||
|
|||
|
|||
publish: |
|||
@if test 0 -ne `git status --porcelain | wc -l` ; then \
|
|||
echo "Unclean working tree. Commit or stash changes first." >&2 ; \
|
|||
exit 128 ; \
|
|||
fi |
|||
@if test 0 -ne `git fetch ; git status | grep '^# Your branch' | wc -l` ; then \
|
|||
echo "Local/Remote history differs. Please push/pull changes." >&2 ; \
|
|||
exit 128 ; \
|
|||
fi |
|||
@if test 0 -ne `git tag -l ${NPM_VERSION} | wc -l` ; then \
|
|||
echo "Tag ${NPM_VERSION} exists. Update package.json" >&2 ; \
|
|||
exit 128 ; \
|
|||
fi |
|||
git tag ${NPM_VERSION} && git push origin ${NPM_VERSION} |
|||
npm publish ${GITHUB_PROJ}/tarball/${NPM_VERSION} |
|||
|
|||
|
|||
browserify: |
|||
rm -rf ./dist |
|||
mkdir dist |
|||
# Browserify |
|||
( echo -n "/* ${NPM_PACKAGE} ${NPM_VERSION} ${GITHUB_PROJ} */" ; \
|
|||
browserify -r ./ -s Remarkable \
|
|||
) > dist/remarkable.js |
|||
# Minify |
|||
uglifyjs dist/remarkable.js -c -m \
|
|||
--preamble "/* ${NPM_PACKAGE} ${NPM_VERSION} ${GITHUB_PROJ} */" \
|
|||
> dist/remarkable.min.js |
|||
|
|||
|
|||
todo: |
|||
grep 'TODO' -n -r ./lib 2>/dev/null || test true |
|||
|
|||
|
|||
.PHONY: publish lint test dev-deps gh-pages todo |
|||
.SILENT: help lint test todo |
@ -0,0 +1,57 @@ |
|||
cooming soon |
|||
|
|||
remarkable |
|||
========== |
|||
|
|||
[![Build Status](https://travis-ci.org/jonschlinkert/remarkable.svg?branch=master)](https://travis-ci.org/jonschlinkert/remarkable) |
|||
[![NPM version](https://img.shields.io/npm/v/remarkable.svg)](https://www.npmjs.org/package/remarkable) |
|||
|
|||
Markdown parser done right. Fast and easy to extend. |
|||
|
|||
/DEMO LINK/ |
|||
|
|||
/INTRO/ |
|||
|
|||
Install |
|||
------- |
|||
|
|||
node.js: |
|||
|
|||
```bash |
|||
npm install remarkable --save |
|||
``` |
|||
|
|||
bower: |
|||
|
|||
```bash |
|||
bower install remarkable --save |
|||
``` |
|||
|
|||
Usage |
|||
----- |
|||
|
|||
```javascript |
|||
var Remarkable = require('remarkable')(); |
|||
var md = new Remarkable(/* options */); |
|||
|
|||
console.log(md.parse('# Remarkable rulezz!')); |
|||
//=> <h1># Remarkable rulezz!</h1> |
|||
``` |
|||
|
|||
You can define options via `set` method: |
|||
|
|||
```javascript |
|||
var Remarkable = require('remarkable')(); |
|||
var md = new Remarkable(); |
|||
|
|||
md.set({ |
|||
gfm: true, |
|||
tables: true, |
|||
breaks: false, |
|||
pedantic: false, |
|||
sanitize: true, |
|||
smartLists: true, |
|||
smartypants: false |
|||
}); |
|||
``` |
|||
|
@ -0,0 +1,139 @@ |
|||
#!/usr/bin/env node
|
|||
|
|||
'use strict'; |
|||
|
|||
var path = require('path'); |
|||
var fs = require('fs'); |
|||
var util = require('util'); |
|||
var Benchmark = require('benchmark'); |
|||
var ansi = require('ansi'); |
|||
var cursor = ansi(process.stdout); |
|||
|
|||
var IMPLS_DIRECTORY = path.join(__dirname, 'implementations'); |
|||
var IMPLS_PATHS = {}; |
|||
var IMPLS = []; |
|||
|
|||
|
|||
fs.readdirSync(IMPLS_DIRECTORY).sort().forEach(function (name) { |
|||
var file = path.join(IMPLS_DIRECTORY, name), |
|||
code = require(file); |
|||
|
|||
IMPLS_PATHS[name] = file; |
|||
IMPLS.push({ |
|||
name: name, |
|||
code: code |
|||
}); |
|||
}); |
|||
|
|||
|
|||
var SAMPLES_DIRECTORY = path.join(__dirname, 'samples'); |
|||
var SAMPLES = []; |
|||
|
|||
fs.readdirSync(SAMPLES_DIRECTORY).sort().forEach(function (sample) { |
|||
var filepath = path.join(SAMPLES_DIRECTORY, sample), |
|||
extname = path.extname(filepath), |
|||
basename = path.basename(filepath, extname); |
|||
|
|||
var content = {}; |
|||
|
|||
content.string = fs.readFileSync(filepath, 'utf8'); |
|||
|
|||
var title = util.format('(%d bytes)', content.string.length); |
|||
|
|||
function onComplete() { |
|||
cursor.write('\n'); |
|||
} |
|||
|
|||
|
|||
var suite = new Benchmark.Suite(title, { |
|||
|
|||
onStart: function onStart() { |
|||
console.log('\nSample: %s %s', sample, title); |
|||
}, |
|||
|
|||
onComplete: onComplete |
|||
|
|||
}); |
|||
|
|||
|
|||
IMPLS.forEach(function (impl) { |
|||
suite.add(impl.name, { |
|||
|
|||
onCycle: function onCycle(event) { |
|||
cursor.horizontalAbsolute(); |
|||
cursor.eraseLine(); |
|||
cursor.write(' > ' + event.target); |
|||
}, |
|||
|
|||
onComplete: onComplete, |
|||
|
|||
defer: !!impl.code.async, |
|||
|
|||
fn: function (deferred) { |
|||
impl.code.run(content.string); |
|||
return; |
|||
} |
|||
}); |
|||
}); |
|||
|
|||
|
|||
SAMPLES.push({ |
|||
name: basename, |
|||
title: title, |
|||
content: content, |
|||
suite: suite |
|||
}); |
|||
}); |
|||
|
|||
|
|||
function select(patterns) { |
|||
var result = []; |
|||
|
|||
if (!(patterns instanceof Array)) { |
|||
patterns = [ patterns ]; |
|||
} |
|||
|
|||
function checkName(name) { |
|||
return patterns.length === 0 || patterns.some(function (regexp) { |
|||
return regexp.test(name); |
|||
}); |
|||
} |
|||
|
|||
SAMPLES.forEach(function (sample) { |
|||
if (checkName(sample.name)) { |
|||
result.push(sample); |
|||
} |
|||
}); |
|||
|
|||
return result; |
|||
} |
|||
|
|||
|
|||
function run(files) { |
|||
var selected = select(files); |
|||
|
|||
if (selected.length > 0) { |
|||
console.log('Selected samples: (%d of %d)', selected.length, SAMPLES.length); |
|||
selected.forEach(function (sample) { |
|||
console.log(' > %s', sample.name); |
|||
}); |
|||
} else { |
|||
console.log('There isn\'t any sample matches any of these patterns: %s', util.inspect(files)); |
|||
} |
|||
|
|||
selected.forEach(function (sample) { |
|||
sample.suite.run(); |
|||
}); |
|||
} |
|||
|
|||
module.exports.IMPLS_DIRECTORY = IMPLS_DIRECTORY; |
|||
module.exports.IMPLS_PATHS = IMPLS_PATHS; |
|||
module.exports.IMPLS = IMPLS; |
|||
module.exports.SAMPLES_DIRECTORY = SAMPLES_DIRECTORY; |
|||
module.exports.SAMPLES = SAMPLES; |
|||
module.exports.select = select; |
|||
module.exports.run = run; |
|||
|
|||
run(process.argv.slice(2).map(function (source) { |
|||
return new RegExp(source, 'i'); |
|||
})); |
@ -0,0 +1,8 @@ |
|||
'use strict' |
|||
|
|||
var Remarkable = new require('../../../'); |
|||
var md = new Remarkable(); |
|||
|
|||
exports.run = function(data) { |
|||
return md.render(data); |
|||
} |
@ -0,0 +1,7 @@ |
|||
'use strict' |
|||
|
|||
var marked = new require('./marked'); |
|||
|
|||
exports.run = function(data) { |
|||
return marked(data); |
|||
} |
File diff suppressed because it is too large
@ -0,0 +1,13 @@ |
|||
Lorem ipsum dolor sit amet, __consectetur__ adipiscing elit. Cras imperdiet nec erat ac condimentum. Nulla vel rutrum ligula. Sed hendrerit interdum orci a posuere. Vivamus ut velit aliquet, mollis purus eget, iaculis nisl. Proin posuere malesuada ante. Proin auctor orci eros, ac molestie lorem dictum nec. Vestibulum sit amet erat est. Morbi luctus sed elit ac luctus. Proin blandit, enim vitae egestas posuere, neque elit ultricies dui, vel mattis nibh enim ac lorem. Maecenas molestie nisl sit amet velit dictum lobortis. Aliquam erat volutpat. |
|||
|
|||
Vivamus sagittis, diam in [vehicula](https://github.com/jonschlinkert/remarked) lobortis, sapien arcu mattis erat, vel aliquet sem urna et risus. Ut feugiat sapien vitae mi elementum laoreet. Suspendisse potenti. Aliquam erat nisl, aliquam pretium libero aliquet, sagittis eleifend nunc. In hac habitasse platea dictumst. Integer turpis augue, tincidunt dignissim mauris id, rhoncus dapibus purus. Maecenas et enim odio. Nullam massa metus, varius quis vehicula sed, pharetra mollis erat. In quis viverra velit. Vivamus placerat, est nec hendrerit varius, enim dui hendrerit magna, ut pulvinar nibh lorem vel lacus. Mauris a orci iaculis, hendrerit eros sed, gravida leo. In dictum mauris vel augue varius, ac ullamcorper nisl ornare. In eu posuere velit, ac fermentum arcu. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nullam sed malesuada leo, at interdum elit. |
|||
|
|||
Nullam ut tincidunt nunc. [Pellentesque][1] metus lacus, commodo eget justo ut, rutrum varius nunc. Sed non rhoncus risus. Morbi sodales gravida pulvinar. Duis malesuada, odio volutpat elementum vulputate, massa magna scelerisque ante, et accumsan tellus nunc in sem. Donec mattis arcu et velit aliquet, non sagittis justo vestibulum. Suspendisse volutpat felis lectus, nec consequat ipsum mattis id. Donec dapibus vehicula facilisis. In tincidunt mi nisi, nec faucibus tortor euismod nec. Suspendisse ante ligula, aliquet vitae libero eu, vulputate dapibus libero. Sed bibendum, sapien at posuere interdum, libero est sollicitudin magna, ac gravida tellus purus eu ipsum. Proin ut quam arcu. |
|||
|
|||
Suspendisse potenti. Donec ante velit, ornare at augue quis, tristique laoreet sem. Etiam in ipsum elit. Nullam cursus dolor sit amet nulla feugiat tristique. Phasellus ac tellus tincidunt, imperdiet purus eget, ullamcorper ipsum. Cras eu tincidunt sem. Nullam sed dapibus magna. Lorem ipsum dolor sit amet, consectetur adipiscing elit. In id venenatis tortor. In consectetur sollicitudin pharetra. Etiam convallis nisi nunc, et aliquam turpis viverra sit amet. Maecenas faucibus sodales tortor. Suspendisse lobortis mi eu leo viverra volutpat. Pellentesque velit ante, vehicula sodales congue ut, elementum a urna. Cras tempor, ipsum eget luctus rhoncus, arcu ligula fermentum urna, vulputate pharetra enim enim non libero. |
|||
|
|||
Proin diam quam, elementum in eleifend id, elementum et metus. Cras in justo consequat justo semper ultrices. Sed dignissim lectus a ante mollis, nec vulputate ante molestie. Proin in porta nunc. Etiam pulvinar turpis sed velit porttitor, vel adipiscing velit fringilla. Cras ac tellus vitae purus pharetra tincidunt. Sed cursus aliquet aliquet. Cras eleifend commodo malesuada. In turpis turpis, ullamcorper ut tincidunt a, ullamcorper a nunc. Etiam luctus tellus ac dapibus gravida. Ut nec lacus laoreet neque ullamcorper volutpat. |
|||
|
|||
Nunc et leo erat. Aenean mattis ultrices lorem, eget adipiscing dolor ultricies eu. In hac habitasse platea dictumst. Vivamus cursus feugiat sapien quis aliquam. Mauris quam libero, porta vel volutpat ut, blandit a purus. Vivamus vestibulum dui vel tortor molestie, sit amet feugiat sem commodo. Nulla facilisi. Sed molestie arcu eget tellus vestibulum tristique. |
|||
|
|||
[1]: https://github.com/jonschlinkert |
@ -0,0 +1,15 @@ |
|||
'use strict'; |
|||
|
|||
function Remarkable(options) { |
|||
|
|||
} |
|||
|
|||
Remarkable.prototype.set = function (options) { |
|||
|
|||
}; |
|||
|
|||
Remarkable.prototype.render = function (src) { |
|||
return ''; |
|||
}; |
|||
|
|||
module.exports = Remarkable; |
@ -0,0 +1,28 @@ |
|||
{ |
|||
"name": "remarkable", |
|||
"version": "1.0.0", |
|||
"homepage": "https://github.com/jonschlinkert/remarkable", |
|||
"repository": { |
|||
"type": "git", |
|||
"url": "git://github.com/jonschlinkert/remarkable.git" |
|||
}, |
|||
"bugs": { |
|||
"url": "https://github.com/jonschlinkert/remarkable/issues" |
|||
}, |
|||
"licenses": [ |
|||
{ |
|||
"type": "MIT", |
|||
"url": "https://github.com/jonschlinkert/remarkable/blob/master/LICENSE" |
|||
} |
|||
], |
|||
"main": "index.js", |
|||
"devDependencies": { |
|||
"ansi": "^0.3.0", |
|||
"benchmark": "^1.0.0", |
|||
"browserify": "*", |
|||
"jshint": "*", |
|||
"mocha": "*", |
|||
"uglifyjs": "*" |
|||
} |
|||
} |
|||
|
Loading…
Reference in new issue