@caganelden/markdjs 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/main.js CHANGED
@@ -1,8 +1,26 @@
1
- import escapeHtml from 'escape.js';
2
- import inlineRegexParser from 'regex.js';
3
-
1
+ // This function uses regex to render html elements by markdown
2
+ const inlineRegexParser = (line) => {
3
+ return (line
4
+ .replace(/`([^`]+)`/g, '<code>$1</code>')
5
+ .replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>')
6
+ .replace(/\*([^\*]+)\*/g, '<em>$1</em>')
7
+ .replace(/\[([^\]]+)\]\(([^\)]+)\)/g, '<a href="$2">$1</a>')
8
+ );
9
+ };
10
+
11
+ // I've written this function for XSS protection
12
+ const escapeHTML = (str) => {
13
+ return str
14
+ .replace(/&/g, '&amp;')
15
+ .replace(/</g, '&lt;')
16
+ .replace(/>/g, '&gt;')
17
+ .replace(/"/g, '&quot;')
18
+ .replace(/'/g, '&#039;');
19
+ };
20
+
21
+ // this is the function which does the job
4
22
  const rendMD = (mdString) => {
5
- const lineArr = escapeHtml(mdString).split(/\r?\n/);
23
+ const lineArr = escapeHTML(mdString).split(/\r?\n/);
6
24
  const renderedArr = [];
7
25
 
8
26
  let listChecker = false;
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "@caganelden/markdjs",
3
- "version": "1.0.0",
4
- "description": "**MarkdJS** is a lightweight & easy-to-use `markdown` to `html` rendering `javascript` library with XSS protection.",
3
+ "version": "1.0.1",
4
+ "description": "MarkdJS is a lightweight & easy-to-use markdown to html rendering javascript library with XSS protection.",
5
5
  "main": "main.js",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1"
8
8
  },
9
- "keywords": [],
9
+ "keywords": [
10
+ "markdown",
11
+ "markdown-rendering",
12
+ "markdown-to-html"
13
+ ],
10
14
  "author": "",
11
15
  "license": "ISC"
12
- }
16
+ }
package/escape.js DELETED
@@ -1,9 +0,0 @@
1
- // I've written this function for XSS protection
2
- const escapeHTML = (str) => {
3
- return str
4
- .replace(/&/g, '&amp;')
5
- .replace(/</g, '&lt;')
6
- .replace(/>/g, '&gt;')
7
- .replace(/"/g, '&quot;')
8
- .replace(/'/g, '&#039;');
9
- };
package/regex.js DELETED
@@ -1,9 +0,0 @@
1
- // This function uses regex to render html elements by markdown
2
- const inlineRegexParser = (line) => {
3
- return (line
4
- .replace(/`([^`]+)`/g, '<code>$1</code>')
5
- .replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>')
6
- .replace(/\*([^\*]+)\*/g, '<em>$1</em>')
7
- .replace(/\[([^\]]+)\]\(([^\)]+)\)/g, '<a href="$2">$1</a>')
8
- );
9
- };