Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
bebraw committed Apr 8, 2016
0 parents commit 7e9687e
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"presets": [
"es2015",
"react"
]
}
24 changes: 24 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// -*- mode: Javascript -*-


// Use this file as a starting point for your project's .eslintrc.
// Copy this file, and add rule overrides as needed.
{
"extends": "airbnb/base",

/**
* Overrides to the airbnb rules
*/
"rules": {
"func-names": 0,
"comma-dangle": [2, "never"],
"no-undef": [2],
"no-undefined": 1,
"no-use-before-define": 0,
// http://eslint.org/docs/rules/prefer-const
"prefer-const": 1,
// http://eslint.org/docs/rules/no-unused-vars.html
"no-unused-vars": [1, {"vars": "all", "args": "after-used"}],
"padded-blocks": [0, "always"],
}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/

20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2016 Juho Vepsalainen

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.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# remark-react-lowlight - Syntax highlighting for remark-react through lowlight

Usage:
37 changes: 37 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _reactLowlight = require('react-lowlight');

var _reactLowlight2 = _interopRequireDefault(_reactLowlight);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var RemarkLowlight = function RemarkLowlight(languageDefinitions) {
Object.keys(languageDefinitions).forEach(function (language) {
var definition = languageDefinitions[language];

_reactLowlight2.default.registerLanguage(language, definition);
});

var Code = function Code(_ref) {
var className = _ref.className;
var children = _ref.children;
return _react2.default.createElement(_reactLowlight2.default, { language: className.split('-')[1], value: children });
};
Code.propTypes = {
className: _react2.default.PropTypes.string,
children: _react2.default.PropTypes.node
};

return Code;
};

exports.default = RemarkLowlight;
36 changes: 36 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "remark-react-lowlight",
"description": "...",
"author": "Juho Vepsalainen <bebraw@gmail.com>",
"version": "0.0.0",
"scripts": {
"build": "babel src -d lib",
"watch": "babel src --watch -d lib",
"lint": "eslint .",
"preversion": "npm run lint && npm run build && git commit --allow-empty -am \"Update lib\""
},
"main": "lib/index.js",
"dependencies": {},
"devDependencies": {
"babel-cli": "^6.6.5",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"eslint": "^2.7.0",
"eslint-config-airbnb": "^6.2.0",
"mocha": "^2.4.5"
},
"repository": {
"type": "git",
"url": "https://github.com/bebraw/remark-react-lowlight.git"
},
"homepage": "https://github.com/bebraw/remark-react-lowlight",
"bugs": {
"url": "https://github.com/bebraw/remark-react-lowlight/issues"
},
"keywords": [
"remark",
"react",
"lowlight"
],
"license": "MIT"
}
22 changes: 22 additions & 0 deletions src/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';
import Lowlight from 'react-lowlight';

const RemarkLowlight = languageDefinitions => {
Object.keys(languageDefinitions).forEach(language => {
const definition = languageDefinitions[language];

Lowlight.registerLanguage(language, definition);
});

const Code = ({className, children}) => (
<Lowlight language={className.split('-')[1]} value={children} />
);
Code.propTypes = {
className: React.PropTypes.string,
children: React.PropTypes.node
};

return Code;
}

export default RemarkLowlight;

0 comments on commit 7e9687e

Please sign in to comment.