-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Vitaly Puzrin
committed
Jan 1, 2015
0 parents
commit 2938016
Showing
14 changed files
with
432 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
coverage/ | ||
dist/ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
env: | ||
node: true | ||
|
||
plugins: | ||
- nodeca | ||
|
||
rules: | ||
block-scoped-var: 2 | ||
brace-style: [ 2, '1tbs', { allowSingleLine: true } ] | ||
comma-spacing: 2 | ||
comma-style: 2 | ||
consistent-this: [ 2, self ] | ||
consistent-return: 2 | ||
curly: 2 | ||
# default-case: 2 | ||
dot-notation: 2 | ||
eol-last: 2 | ||
eqeqeq: 2 | ||
guard-for-in: 2 | ||
handle-callback-err: 2 | ||
max-depth: [ 1, 6 ] | ||
max-nested-callbacks: [ 1, 4 ] | ||
# string can exceed 80 chars, but should not overflow github website :) | ||
max-len: [ 2, 120, 1000 ] | ||
new-cap: 2 | ||
new-parens: 2 | ||
no-alert: 2 | ||
no-array-constructor: 2 | ||
no-bitwise: 2 | ||
no-caller: 2 | ||
no-catch-shadow: 2 | ||
no-comma-dangle: 2 | ||
no-cond-assign: 2 | ||
no-console: 1 | ||
no-constant-condition: 2 | ||
no-control-regex: 2 | ||
no-debugger: 2 | ||
no-delete-var: 2 | ||
no-dupe-keys: 2 | ||
no-div-regex: 2 | ||
no-empty: 2 | ||
no-empty-class: 2 | ||
no-empty-label: 2 | ||
no-else-return: 2 | ||
no-eq-null: 2 | ||
no-ex-assign: 2 | ||
no-extend-native: 2 | ||
no-extra-bind: 2 | ||
no-extra-boolean-cast: 2 | ||
no-extra-semi: 2 | ||
no-extra-strict: 2 | ||
no-eval: 2 | ||
no-floating-decimal: 2 | ||
no-func-assign: 2 | ||
no-implied-eval: 2 | ||
no-inner-declarations: 2 | ||
no-invalid-regexp: 2 | ||
no-irregular-whitespace: 2 | ||
no-label-var: 2 | ||
no-labels: 2 | ||
no-lone-blocks: 2 | ||
no-lonely-if: 2 | ||
no-loop-func: 2 | ||
no-mixed-requires: 2 | ||
no-mixed-spaces-and-tabs: 2 | ||
no-multi-str: 2 | ||
no-native-reassign: 2 | ||
no-negated-in-lhs: 2 | ||
no-new: 2 | ||
no-new-func: 2 | ||
no-new-object: 2 | ||
no-new-require: 2 | ||
no-new-wrappers: 2 | ||
no-obj-calls: 2 | ||
no-octal: 2 | ||
no-octal-escape: 2 | ||
no-path-concat: 2 | ||
no-redeclare: 2 | ||
no-regex-spaces: 2 | ||
no-reserved-keys: 2 | ||
no-return-assign: 2 | ||
no-script-url: 2 | ||
no-sequences: 2 | ||
no-shadow: 2 | ||
no-shadow-restricted-names: 2 | ||
no-space-before-semi: 2 | ||
no-sparse-arrays: 2 | ||
no-trailing-spaces: 2 | ||
no-undef: 2 | ||
no-undef-init: 2 | ||
no-undefined: 2 | ||
no-unreachable: 2 | ||
no-unused-expressions: 2 | ||
no-unused-vars: 2 | ||
no-use-before-define: 2 | ||
no-with: 2 | ||
no-wrap-func: 2 | ||
quotes: [ 2, single, avoid-escape ] | ||
radix: 2 | ||
semi: 2 | ||
space-after-keywords: [ 2, always, , { "checkFunctionKeyword": true } ] | ||
space-before-blocks: 2 | ||
space-in-brackets: [ 2, always, { propertyName: false } ] | ||
space-in-parens: [ 2, never ] | ||
space-infix-ops: 2 | ||
space-return-throw-case: 2 | ||
space-unary-ops: 2 | ||
spaced-line-comment: [ 2, always, { exceptions: [ '/' ] } ] | ||
strict: 2 | ||
use-isnan: 2 | ||
yoda: 2 | ||
valid-typeof: 2 | ||
|
||
# | ||
# Our custom rules | ||
# | ||
nodeca/indent: [ 2, spaces, 2 ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules/ | ||
coverage/ | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
coverage/ | ||
support/ | ||
test/ | ||
Makefile | ||
.* | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
language: node_js | ||
node_js: | ||
- '0.10' | ||
script: make test-ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
0.1.0 / WIP | ||
------------------ | ||
|
||
- First release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Copyright (c) 2014-2015 Vitaly Puzrin, Alex Kocharin. | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
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//markdown-it/${NPM_PACKAGE} | ||
|
||
|
||
lint: | ||
./node_modules/.bin/eslint --reset . | ||
|
||
test: lint | ||
./node_modules/.bin/mocha -R spec | ||
|
||
coverage: | ||
rm -rf coverage | ||
./node_modules/.bin/istanbul cover node_modules/.bin/_mocha | ||
|
||
test-ci: lint | ||
istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage | ||
|
||
browserify: | ||
rm -rf ./dist | ||
mkdir dist | ||
# Browserify | ||
( printf "/*! ${NPM_PACKAGE} ${NPM_VERSION} ${GITHUB_PROJ} @license MIT */" ; \ | ||
./node_modules/.bin/browserify ./ -s markdownitSup \ | ||
) > dist/markdown-it-sup.js | ||
# Minify | ||
./node_modules/.bin/uglifyjs dist/markdown-it-sup.js -b beautify=false,ascii-only=true -c -m \ | ||
--preamble "/*! ${NPM_PACKAGE} ${NPM_VERSION} ${GITHUB_PROJ} @license MIT */" \ | ||
> dist/markdown-it-sup.min.js | ||
|
||
.PHONY: lint test coverage | ||
.SILENT: lint test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# markdown-it-sup | ||
|
||
[![Build Status](https://img.shields.io/travis/markdown-it/markdown-it-sup/master.svg?style=flat)](https://travis-ci.org/markdown-it/markdown-it-sup) | ||
[![NPM version](https://img.shields.io/npm/v/markdown-it-sup.svg?style=flat)](https://www.npmjs.org/package/markdown-it-sup) | ||
[![Coverage Status](https://img.shields.io/coveralls/markdown-it/markdown-it-sup/master.svg?style=flat)](https://coveralls.io/r/markdown-it/markdown-it-sup?branch=master) | ||
|
||
> Superscript (`<sup>`) tag plugin for [markdown-it](https://github.com/markdown-it/markdown-it) markdown parser. | ||
`29^th^` => `29<sup>th</sup>` | ||
|
||
Markup is based on [pandoc](http:https://johnmacfarlane.net/pandoc/README.html#superscripts-and-subscripts) definition. But nested markup is currently not supported. | ||
|
||
|
||
## Install | ||
|
||
node.js, browser: | ||
|
||
```bash | ||
npm install markdown-it-sup --save | ||
bower install markdown-it-sup --save | ||
``` | ||
|
||
## Use | ||
|
||
```js | ||
var md = require('markdown-it')() | ||
.use(require('markdown-it-sup')); | ||
|
||
md.render('29^th') // => '<p>29<sup>th</sup></p>' | ||
``` | ||
|
||
_Differences in browser._ If you load script directly into the page, without | ||
package system, module will add itself globally as `window.markdownitSup`. | ||
|
||
|
||
## License | ||
|
||
[MIT](https://github.com/markdown-it/markdown-it-sup/blob/master/LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "markdown-it-sup", | ||
"main": "dist/markdown-it-sup.js", | ||
"homepage": "https://github.com/markdown-it/markdown-it-sup", | ||
"description": "<ins> tag for markdown-it markdown parser.", | ||
"keywords": [ | ||
"markdown-it-plugin", | ||
"markdown-it", | ||
"markdown", | ||
"superscript", | ||
"sup" | ||
], | ||
"license": "MIT", | ||
"ignore": [ | ||
"**/.*", | ||
"benchmark", | ||
"bower_components", | ||
"coverage", | ||
"demo", | ||
"docs", | ||
"lib", | ||
"node_modules", | ||
"support", | ||
"test", | ||
"Makefile", | ||
"index*" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Process ^superscript^ | ||
|
||
'use strict'; | ||
|
||
// same as UNESCAPE_MD_RE plus a space | ||
var UNESCAPE_RE = /\\([ \\!"#$%&'()*+,.\/:;<=>?@[\]^_`{|}~-])/g; | ||
|
||
function superscript(state, silent) { | ||
var found, | ||
content, | ||
max = state.posMax, | ||
start = state.pos; | ||
|
||
if (state.src.charCodeAt(start) !== 0x5E/* ^ */) { return false; } | ||
if (silent) { return false; } // don't run any pairs in validation mode | ||
if (start + 2 >= max) { return false; } | ||
|
||
state.pos = start + 1; | ||
|
||
while (state.pos < max) { | ||
if (state.src.charCodeAt(state.pos) === 0x5E/* ^ */) { | ||
found = true; | ||
break; | ||
} | ||
|
||
state.md.inline.skipToken(state); | ||
} | ||
|
||
if (!found || start + 1 === state.pos) { | ||
state.pos = start; | ||
return false; | ||
} | ||
|
||
content = state.src.slice(start + 1, state.pos); | ||
|
||
// don't allow unescaped spaces/newlines inside | ||
if (content.match(/(^|[^\\])(\\\\)*\s/)) { | ||
state.pos = start; | ||
return false; | ||
} | ||
|
||
// found! | ||
state.posMax = state.pos; | ||
state.pos = start + 1; | ||
|
||
// Earlier we checked !silent, but this implementation does not need it | ||
state.push({ type: 'sup_open', level: state.level++ }); | ||
state.push({ | ||
type: 'text', | ||
level: state.level, | ||
content: content.replace(UNESCAPE_RE, '$1') | ||
}); | ||
state.push({ type: 'sup_close', level: --state.level }); | ||
|
||
state.pos = state.posMax + 1; | ||
state.posMax = max; | ||
return true; | ||
} | ||
|
||
|
||
function sup_open() { return '<sup>'; } | ||
function sup_close() { return '</sup>'; } | ||
|
||
|
||
module.exports = function sup_plugin(md) { | ||
md.inline.ruler.after('emphasis', 'sup', superscript); | ||
md.renderer.rules.sup_open = sup_open; | ||
md.renderer.rules.sup_close = sup_close; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"name": "markdown-it-sup", | ||
"version": "0.1.0", | ||
"description": "<ins> tag for markdown-it markdown parser.", | ||
"keywords": [ | ||
"markdown-it-plugin", | ||
"markdown-it", | ||
"markdown", | ||
"superscript", | ||
"sup" | ||
], | ||
"homepage": "https://github.com/markdown-it/markdown-it-sup", | ||
"repository": { | ||
"type": "git", | ||
"url": "git:https://github.com/markdown-it/markdown-it-sup.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/markdown-it/markdown-it-sup/issues" | ||
}, | ||
"license": "MIT", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "make test" | ||
}, | ||
"devDependencies": { | ||
"browserify": "*", | ||
"coveralls": "^2.11.2", | ||
"eslint": "0.10.2", | ||
"eslint-plugin-nodeca": "^1.0.0", | ||
"istanbul": "*", | ||
"lodash": "*", | ||
"markdown-it": "git:https://github.com/markdown-it/markdown-it.git#next", | ||
"markdown-it-testgen": "~0.1.0", | ||
"mocha": "*", | ||
"request": "*", | ||
"uglify-js": "*" | ||
} | ||
} |
Oops, something went wrong.