master b9b083c0ed4c cached
11 files
21.1 KB
6.7k tokens
1 requests
Download .txt
Repository: christianalfoni/markdown-to-react-components
Branch: master
Commit: b9b083c0ed4c
Files: 11
Total size: 21.1 KB

Directory structure:
gitextract_gwo92svq/

├── .gitignore
├── ISSUE_TEMPLATE.md
├── LICENSE
├── README.md
├── app/
│   ├── main.js
│   ├── prism.css
│   └── prism.js
├── package.json
├── src/
│   ├── CodeComponent.js
│   └── index.js
└── webpack.config.js

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
node_modules


================================================
FILE: ISSUE_TEMPLATE.md
================================================
This repo is DEPRECATED, please create issues over at: https://github.com/cerebral/marksy


================================================
FILE: LICENSE
================================================
The MIT License (MIT)

Copyright (c) 2015 Christian Alfoni

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.



================================================
FILE: README.md
================================================
# markdown-to-react-components
Convert markdown into react components

## DEPRECATED
This repo is DEPRECATED, please go to: https://github.com/cerebral/marksy


================================================
FILE: app/main.js
================================================
require('./prism.css');
require('./prism.js');
var React = require('react');
var lib = require('markdown-to-react-components');
var DOM = React.DOM;

var HalfColumn = {
  width: '50%',
  verticalAlign: 'top',
  display: 'inline-block'
};

lib.configure({
  h1: React.createClass({
    render: function () {
      return DOM.h1({
        style: {color: 'red'}
      }, this.props.children)
    }
  })
});

var App = React.createClass({
  getInitialState: function () {
    return {
      tree: null
    };
  },
  onTextareaChange: function (event) {
    this.setState({
      tree: lib(event.target.value).tree
    });
  },
  render: function () {
    return DOM.div(null,
      DOM.div({
        style: HalfColumn
      }, this.state.tree),
      DOM.textarea({
        style: {
          width: 500,
          height: 500
        },
        onChange: this.onTextareaChange
      })
    );
  }
});

React.render(React.createElement(App), document.body);


================================================
FILE: app/prism.css
================================================
/* http://prismjs.com/download.html?themes=prism&languages=markup+clike+javascript+jsx */
/**
 * prism.js default theme for JavaScript, CSS and HTML
 * Based on dabblet (http://dabblet.com)
 * @author Lea Verou
 */

code[class*="language-"],
pre[class*="language-"] {
	color: black;
	background: none;
	text-shadow: 0 1px white;
	font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
	direction: ltr;
	text-align: left;
	white-space: pre;
	word-spacing: normal;
	word-break: normal;
	word-wrap: normal;
	line-height: 1.5;

	-moz-tab-size: 4;
	-o-tab-size: 4;
	tab-size: 4;

	-webkit-hyphens: none;
	-moz-hyphens: none;
	-ms-hyphens: none;
	hyphens: none;
}

pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
	text-shadow: none;
	background: #b3d4fc;
}

pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
code[class*="language-"]::selection, code[class*="language-"] ::selection {
	text-shadow: none;
	background: #b3d4fc;
}

@media print {
	code[class*="language-"],
	pre[class*="language-"] {
		text-shadow: none;
	}
}

/* Code blocks */
pre[class*="language-"] {
	padding: 1em;
	margin: .5em 0;
	overflow: auto;
}

:not(pre) > code[class*="language-"],
pre[class*="language-"] {
	background: #f5f2f0;
}

/* Inline code */
:not(pre) > code[class*="language-"] {
	padding: .1em;
	border-radius: .3em;
	white-space: normal;
}

.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
	color: slategray;
}

.token.punctuation {
	color: #999;
}

.namespace {
	opacity: .7;
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
	color: #905;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
	color: #690;
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
	color: #a67f59;
	background: hsla(0, 0%, 100%, .5);
}

.token.atrule,
.token.attr-value,
.token.keyword {
	color: #07a;
}

.token.function {
	color: #DD4A68;
}

.token.regex,
.token.important,
.token.variable {
	color: #e90;
}

.token.important,
.token.bold {
	font-weight: bold;
}
.token.italic {
	font-style: italic;
}

.token.entity {
	cursor: help;
}


================================================
FILE: app/prism.js
================================================
/* http://prismjs.com/download.html?themes=prism&languages=markup+clike+javascript+jsx */
var _self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{},Prism=function(){var e=/\blang(?:uage)?-(\w+)\b/i,t=_self.Prism={util:{encode:function(e){return e instanceof n?new n(e.type,t.util.encode(e.content),e.alias):"Array"===t.util.type(e)?e.map(t.util.encode):e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/\u00a0/g," ")},type:function(e){return Object.prototype.toString.call(e).match(/\[object (\w+)\]/)[1]},clone:function(e){var n=t.util.type(e);switch(n){case"Object":var a={};for(var r in e)e.hasOwnProperty(r)&&(a[r]=t.util.clone(e[r]));return a;case"Array":return e.map&&e.map(function(e){return t.util.clone(e)})}return e}},languages:{extend:function(e,n){var a=t.util.clone(t.languages[e]);for(var r in n)a[r]=n[r];return a},insertBefore:function(e,n,a,r){r=r||t.languages;var l=r[e];if(2==arguments.length){a=arguments[1];for(var i in a)a.hasOwnProperty(i)&&(l[i]=a[i]);return l}var o={};for(var s in l)if(l.hasOwnProperty(s)){if(s==n)for(var i in a)a.hasOwnProperty(i)&&(o[i]=a[i]);o[s]=l[s]}return t.languages.DFS(t.languages,function(t,n){n===r[e]&&t!=e&&(this[t]=o)}),r[e]=o},DFS:function(e,n,a,r){r=r||{};for(var l in e)e.hasOwnProperty(l)&&(n.call(e,l,e[l],a||l),"Object"!==t.util.type(e[l])||r[e[l]]?"Array"!==t.util.type(e[l])||r[e[l]]||(r[e[l]]=!0,t.languages.DFS(e[l],n,l,r)):(r[e[l]]=!0,t.languages.DFS(e[l],n,null,r)))}},plugins:{},highlightAll:function(e,n){for(var a,r=document.querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'),l=0;a=r[l++];)t.highlightElement(a,e===!0,n)},highlightElement:function(n,a,r){for(var l,i,o=n;o&&!e.test(o.className);)o=o.parentNode;o&&(l=(o.className.match(e)||[,""])[1],i=t.languages[l]),n.className=n.className.replace(e,"").replace(/\s+/g," ")+" language-"+l,o=n.parentNode,/pre/i.test(o.nodeName)&&(o.className=o.className.replace(e,"").replace(/\s+/g," ")+" language-"+l);var s=n.textContent,u={element:n,language:l,grammar:i,code:s};if(!s||!i)return t.hooks.run("complete",u),void 0;if(t.hooks.run("before-highlight",u),a&&_self.Worker){var c=new Worker(t.filename);c.onmessage=function(e){u.highlightedCode=e.data,t.hooks.run("before-insert",u),u.element.innerHTML=u.highlightedCode,r&&r.call(u.element),t.hooks.run("after-highlight",u),t.hooks.run("complete",u)},c.postMessage(JSON.stringify({language:u.language,code:u.code,immediateClose:!0}))}else u.highlightedCode=t.highlight(u.code,u.grammar,u.language),t.hooks.run("before-insert",u),u.element.innerHTML=u.highlightedCode,r&&r.call(n),t.hooks.run("after-highlight",u),t.hooks.run("complete",u)},highlight:function(e,a,r){var l=t.tokenize(e,a);return n.stringify(t.util.encode(l),r)},tokenize:function(e,n){var a=t.Token,r=[e],l=n.rest;if(l){for(var i in l)n[i]=l[i];delete n.rest}e:for(var i in n)if(n.hasOwnProperty(i)&&n[i]){var o=n[i];o="Array"===t.util.type(o)?o:[o];for(var s=0;s<o.length;++s){var u=o[s],c=u.inside,g=!!u.lookbehind,f=0,h=u.alias;u=u.pattern||u;for(var p=0;p<r.length;p++){var d=r[p];if(r.length>e.length)break e;if(!(d instanceof a)){u.lastIndex=0;var m=u.exec(d);if(m){g&&(f=m[1].length);var y=m.index-1+f,m=m[0].slice(f),v=m.length,k=y+v,b=d.slice(0,y+1),w=d.slice(k+1),P=[p,1];b&&P.push(b);var A=new a(i,c?t.tokenize(m,c):m,h);P.push(A),w&&P.push(w),Array.prototype.splice.apply(r,P)}}}}}return r},hooks:{all:{},add:function(e,n){var a=t.hooks.all;a[e]=a[e]||[],a[e].push(n)},run:function(e,n){var a=t.hooks.all[e];if(a&&a.length)for(var r,l=0;r=a[l++];)r(n)}}},n=t.Token=function(e,t,n){this.type=e,this.content=t,this.alias=n};if(n.stringify=function(e,a,r){if("string"==typeof e)return e;if("Array"===t.util.type(e))return e.map(function(t){return n.stringify(t,a,e)}).join("");var l={type:e.type,content:n.stringify(e.content,a,r),tag:"span",classes:["token",e.type],attributes:{},language:a,parent:r};if("comment"==l.type&&(l.attributes.spellcheck="true"),e.alias){var i="Array"===t.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(l.classes,i)}t.hooks.run("wrap",l);var o="";for(var s in l.attributes)o+=(o?" ":"")+s+'="'+(l.attributes[s]||"")+'"';return"<"+l.tag+' class="'+l.classes.join(" ")+'" '+o+">"+l.content+"</"+l.tag+">"},!_self.document)return _self.addEventListener?(_self.addEventListener("message",function(e){var n=JSON.parse(e.data),a=n.language,r=n.code,l=n.immediateClose;_self.postMessage(t.highlight(r,t.languages[a],a)),l&&_self.close()},!1),_self.Prism):_self.Prism;var a=document.currentScript||[].slice.call(document.getElementsByTagName("script")).pop();return a&&(t.filename=a.src,document.addEventListener&&!a.hasAttribute("data-manual")&&document.addEventListener("DOMContentLoaded",t.highlightAll)),_self.Prism}();"undefined"!=typeof module&&module.exports&&(module.exports=Prism),"undefined"!=typeof global&&(global.Prism=Prism);
Prism.languages.markup={comment:/<!--[\w\W]*?-->/,prolog:/<\?[\w\W]+?\?>/,doctype:/<!DOCTYPE[\w\W]+?>/,cdata:/<!\[CDATA\[[\w\W]*?]]>/i,tag:{pattern:/<\/?(?!\d)[^\s>\/=.$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,inside:{tag:{pattern:/^<\/?[^\s>\/]+/i,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"attr-value":{pattern:/=(?:('|")[\w\W]*?(\1)|[^\s>]+)/i,inside:{punctuation:/[=>"']/}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:/&#?[\da-z]{1,8};/i},Prism.hooks.add("wrap",function(a){"entity"===a.type&&(a.attributes.title=a.content.replace(/&amp;/,"&"))}),Prism.languages.xml=Prism.languages.markup,Prism.languages.html=Prism.languages.markup,Prism.languages.mathml=Prism.languages.markup,Prism.languages.svg=Prism.languages.markup;
Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\w\W]*?\*\//,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0}],string:/(["'])(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,"class-name":{pattern:/((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,"boolean":/\b(true|false)\b/,"function":/[a-z0-9_]+(?=\()/i,number:/\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,operator:/--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,punctuation:/[{}[\];(),.:]/};
Prism.languages.javascript=Prism.languages.extend("clike",{keyword:/\b(as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)\b/,number:/\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,"function":/[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\()/i}),Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^\/])\/(?!\/)(\[.+?]|\\.|[^\/\\\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0}}),Prism.languages.insertBefore("javascript","class-name",{"template-string":{pattern:/`(?:\\`|\\?[^`])*`/,inside:{interpolation:{pattern:/\$\{[^}]+\}/,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}}}),Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{script:{pattern:/(<script[\w\W]*?>)[\w\W]*?(?=<\/script>)/i,lookbehind:!0,inside:Prism.languages.javascript,alias:"language-javascript"}}),Prism.languages.js=Prism.languages.javascript;
!function(a){var e=a.util.clone(a.languages.javascript);a.languages.jsx=a.languages.extend("markup",e),a.languages.jsx.tag.pattern=/<\/?[\w\.:-]+\s*(?:\s+[\w\.:-]+(?:=(?:("|')(\\?[\w\W])*?\1|[^\s'">=]+|(\{[\w\W]*?\})))?\s*)*\/?>/i,a.languages.jsx.tag.inside["attr-value"].pattern=/=[^\{](?:('|")[\w\W]*?(\1)|[^\s>]+)/i;var s=a.util.clone(a.languages.jsx);delete s.punctuation,s=a.languages.insertBefore("jsx","operator",{punctuation:/=(?={)|[{}[\];(),.:]/},{jsx:s}),a.languages.insertBefore("inside","attr-value",{script:{pattern:/=(\{(?:\{[^}]*\}|[^}])+\})/i,inside:s,alias:"language-javascript"}},a.languages.jsx.tag)}(Prism);


================================================
FILE: package.json
================================================
{
  "name": "markdown-to-react-components",
  "version": "0.2.4",
  "description": "Convert markdown into react components",
  "main": "src/index.js",
  "scripts": {
    "start": "webpack-dev-server --devtool eval-source-map --progress --colors --content-base build",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/christianalfoni/markdown-to-react-components"
  },
  "keywords": [
    "react",
    "markdown",
    "convert"
  ],
  "author": "Christian Alfoni",
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/christianalfoni/markdown-to-react-components/issues"
  },
  "homepage": "https://github.com/christianalfoni/markdown-to-react-components",
  "devDependencies": {
    "css-loader": "^0.15.2",
    "json-loader": "^0.5.2",
    "node-libs-browser": "^0.5.2",
    "react": "^0.14.7",
    "style-loader": "^0.12.3",
    "webpack": "^1.10.0",
    "webpack-dev-server": "^1.10.1"
  },
  "dependencies": {
    "he": "^1.1.0",
    "marked": "^0.3.3"
  }
}


================================================
FILE: src/CodeComponent.js
================================================
var React = require('react');

var CodeComponent = React.createClass({
  componentDidMount: function () {
    if (typeof Prism === 'undefined') {
      console.warn('You do not have Prism included as a global object');
      return;
    }
    Prism.highlightAll();
  },
  componentDidUpdate: function () {
    if (typeof Prism === 'undefined') {
      console.warn('You do not have Prism included as a global object');
      return;
    }
    Prism.highlightAll();
  },
  render: function () {
    return React.createElement('pre', {key: this.props.key},
      React.createElement('code', {
          ref: 'code',
          className: 'language-' + this.props.language
        }, this.props.code)
    );
  }
});

module.exports = CodeComponent;


================================================
FILE: src/index.js
================================================
var React = require('react');
var marked = require('marked');
var he = require('he');
var CodeComponent = React.createFactory(require('./CodeComponent.js'));
var renderer = new marked.Renderer();
var options = {};
var inlineIds = 0;
var keys = 0;
var inlines = {};
var result = [];
var toc = [];

// Converts inline IDs to actual elements
var createBlockContent = function (content) {
  var textWithInlines = content.split(/(\{\{.*?\}\})/);
  content = textWithInlines.map(function (text) {
    var inline = text.match(/\{\{(.*)\}\}/);
    if (inline) {
      return inlines[inline[1]];
    } else {
			if (text != '') {
      	return he.decode(text);
			}
    }
  });

  return content;
};

var getTocPosition = function (toc, level) {
  var currentLevel = toc.children;
  while (true) {
    if (!currentLevel.length || currentLevel[currentLevel.length - 1].level === level) {
      return currentLevel;
    } else {
      currentLevel = currentLevel[currentLevel.length - 1].children;
    }
  }
};

renderer.code = function (code, language) {
  var props = {
    key: keys++,
    language: language,
    code: code
  };

  if (options.code) {
    result.push(React.createElement(options.code, props));
  } else {
    result.push(CodeComponent(props));
  }
};

renderer.blockquote = function (text) {
  var count = text.split(/(\{\{.*?\}\})/).filter(function(n){ return n != ""});

  count.forEach(function(){
    result.pop();
  });

  result.push(React.createElement(options.blockquote || 'blockquote', {key: keys++}, createBlockContent(text)));
};

renderer.html = function (html) {
    result.push(React.createElement(options.html || React.createClass({
        render: function render () {
            return React.createElement('div', {
                dangerouslySetInnerHTML: {
                    __html: this.props.html
                }
            });
        }
    }), {
        html: html
    }));
};

renderer.heading = function (text, level) {
  var type = 'h' + level;
  type = options[type] || type;
  var id = text.replace(/\s/g, '-').toLowerCase();
  var lastToc = toc[toc.length -1];
  if (!lastToc || lastToc.level > level) {
    toc.push({
      id: id,
      title: text,
      level: level,
      children: []
    });
  } else {
    var tocPosition = getTocPosition(lastToc, level);
    tocPosition.push({
      id: id,
      title: text,
      level: level,
      children: []
    });
  }
  var inId = inlineIds++;
  inlines[inId] = React.createElement(type, {
    key: keys++,
    id: id
  },
    createBlockContent(text));
  result.push(inlines[inId]);
  return '{{' + inId + '}}';
};

renderer.hr = function () {
  result.push(React.createElement(options.hr || 'hr', {key: keys++}));
};

renderer.list = function (body, ordered) {
  var id = inlineIds++;
  inlines[id] = React.createElement(ordered ? options.ol || 'ol' : options.ul || 'ul', {key: keys++}, createBlockContent(body));
  result.push(inlines[id]);
  return '{{' + id + '}}';

};

renderer.listitem = function (text) {
  var id = inlineIds++;
  inlines[id] = React.createElement(options.li || 'li', {key: keys++}, createBlockContent(text));
  return '{{' + id + '}}';
};

renderer.paragraph = function (text) {
  var id = inlineIds++;
  inlines[id] = React.createElement(options.p || 'p', {key: keys++}, createBlockContent(text));
  result.push(inlines[id]);
  return '{{' + id + '}}';
};

renderer.table = function (header, body) {
  var id = inlineIds++;
  inlines[id] =  React.createElement(options.table || 'table', {key: keys++},
    React.createElement(options.thead || 'thead', null, createBlockContent(header)),
    React.createElement(options.tbody || 'tbody', null, createBlockContent(body))
  );
  result.push(inlines[id]);
  return '{{' + id + '}}';
};

renderer.thead = function (content) {
  var id = inlineIds++;
  inlines[id] = React.createElement(options.thead || 'thead', {key: keys++}, createBlockContent(content));
  return '{{' + id + '}}';
};

renderer.tbody = function (content) {
  var id = inlineIds++;
  inlines[id] = React.createElement(options.tbody || 'tbody', {key: keys++}, createBlockContent(content));
  return '{{' + id + '}}';
};

renderer.tablerow = function (content) {
  var id = inlineIds++;
  inlines[id] = React.createElement(options.tr || 'tr', {key: keys++}, createBlockContent(content));
  return '{{' + id + '}}';
};

renderer.tablecell = function (content, flags) {
  var id = inlineIds++;
  var props =  flags.align ? {className: 'text-' + flags.align} : {key: keys++};
  inlines[id] = React.createElement(flags.header ? options.th || 'th' : options.td || 'td', props, createBlockContent(content));
  return '{{' + id + '}}';
};

renderer.link = function (href, title, text) {
  var id = inlineIds++;
  inlines[id] = React.createElement(options.a || 'a', {
    href: href,
    title: title,
    key: keys++,
    target: 'new'
  }, createBlockContent(text));
  return '{{' + id + '}}';
};

renderer.strong = function (text) {
  var id = inlineIds++;
  inlines[id] = React.createElement(options.strong || 'strong', {key: keys++}, createBlockContent(text));
  return '{{' + id + '}}';
};

renderer.em = function (text) {
  var id = inlineIds++;
  inlines[id] = React.createElement(options.em || 'em', {key: keys++}, createBlockContent(text));
  return '{{' + id + '}}';
};

renderer.codespan = function (text) {
  var id = inlineIds++;
  inlines[id] = React.createElement(options.codespan || 'code', {key: keys++}, he.decode(text));
  return '{{' + id + '}}';
};

renderer.br = function () {
  var id = inlineIds++;
  inlines[id] = React.createElement(options.br || 'br', {key: keys++});
  return '{{' + id + '}}';
};

renderer.del = function (text) {
  var id = inlineIds++;
  inlines[id] = React.createElement(options.del || 'del', {key: keys++}, he.decode(text));
  return '{{' + id + '}}';
};

renderer.image = function (href, title, text) {
  var id = inlineIds++;
  inlines[id] = React.createElement(options.img || 'img', {src: href, alt: title, key: keys++});
  return '{{' + id + '}}';
};

var exec = function (content) {
  result = [];
  toc = [];
  inlines = {};
  keys = 0;
  marked(content, {renderer: renderer, smartypants: true});
  return {
    tree: result,
    toc: toc
  };
};

exec.configure = function (newOptions) {
  options = newOptions;
};

module.exports = exec;


================================================
FILE: webpack.config.js
================================================
var path = require('path');

var sourcePath = path.resolve(__dirname, 'src', 'index.js');
var appPath = path.resolve(__dirname, 'app', 'main.js');

module.exports = {
  entry: [
    'webpack-dev-server/client?http://localhost:8080',
    appPath
  ],
  output: {
    path: './build',
    filename: 'bundle.js'
  },
  resolve: {
    alias: {
      'markdown-to-react-components': sourcePath
    }
  },
  module: {
    loaders: [{
      test: /\.json$/,
      loader: 'json'
    }, {
      test: /\.css$/,
      loader: 'style!css'
    }]
  }
};
Download .txt
gitextract_gwo92svq/

├── .gitignore
├── ISSUE_TEMPLATE.md
├── LICENSE
├── README.md
├── app/
│   ├── main.js
│   ├── prism.css
│   └── prism.js
├── package.json
├── src/
│   ├── CodeComponent.js
│   └── index.js
└── webpack.config.js
Condensed preview — 11 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (23K chars).
[
  {
    "path": ".gitignore",
    "chars": 13,
    "preview": "node_modules\n"
  },
  {
    "path": "ISSUE_TEMPLATE.md",
    "chars": 90,
    "preview": "This repo is DEPRECATED, please create issues over at: https://github.com/cerebral/marksy\n"
  },
  {
    "path": "LICENSE",
    "chars": 1084,
    "preview": "The MIT License (MIT)\n\nCopyright (c) 2015 Christian Alfoni\n\nPermission is hereby granted, free of charge, to any person "
  },
  {
    "path": "README.md",
    "chars": 159,
    "preview": "# markdown-to-react-components\nConvert markdown into react components\n\n## DEPRECATED\nThis repo is DEPRECATED, please go "
  },
  {
    "path": "app/main.js",
    "chars": 954,
    "preview": "require('./prism.css');\nrequire('./prism.js');\nvar React = require('react');\nvar lib = require('markdown-to-react-compon"
  },
  {
    "path": "app/prism.css",
    "chars": 2329,
    "preview": "/* http://prismjs.com/download.html?themes=prism&languages=markup+clike+javascript+jsx */\n/**\n * prism.js default theme "
  },
  {
    "path": "app/prism.js",
    "chars": 8347,
    "preview": "/* http://prismjs.com/download.html?themes=prism&languages=markup+clike+javascript+jsx */\nvar _self=\"undefined\"!=typeof "
  },
  {
    "path": "package.json",
    "chars": 1055,
    "preview": "{\n  \"name\": \"markdown-to-react-components\",\n  \"version\": \"0.2.4\",\n  \"description\": \"Convert markdown into react componen"
  },
  {
    "path": "src/CodeComponent.js",
    "chars": 745,
    "preview": "var React = require('react');\n\nvar CodeComponent = React.createClass({\n  componentDidMount: function () {\n    if (typeof"
  },
  {
    "path": "src/index.js",
    "chars": 6325,
    "preview": "var React = require('react');\nvar marked = require('marked');\nvar he = require('he');\nvar CodeComponent = React.createFa"
  },
  {
    "path": "webpack.config.js",
    "chars": 543,
    "preview": "var path = require('path');\n\nvar sourcePath = path.resolve(__dirname, 'src', 'index.js');\nvar appPath = path.resolve(__d"
  }
]

About this extraction

This page contains the full source code of the christianalfoni/markdown-to-react-components GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 11 files (21.1 KB), approximately 6.7k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!