Skip to content

Commit

Permalink
Migrated to Electron 1.4.1, added code highlighting and used latest v…
Browse files Browse the repository at this point in the history
…ersion of marked
  • Loading branch information
amitmerchant1990 committed Jan 24, 2017
1 parent fcd9b56 commit 4db8164
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 12 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

* LivePreview - Make changes, See changes
- Instantly see what your Markdown documents look like in HTML as you create them.
* Sync Scrolling
- While you type, LivePreview will automatically scroll to the current location you're editing.
* GitHub Flavored Markdown
* Syntax highlighting
Expand Down Expand Up @@ -66,6 +67,7 @@ This software uses code from several open source packages.
- [showdown](http://showdownjs.github.io/showdown/)
- [CodeMirror](http://codemirror.net/)
- Emojis are taken from [here](https://github.com/arvida/emoji-cheat-sheet.com)
- [highlight.js](https://highlightjs.org/)

## Related

Expand Down
99 changes: 99 additions & 0 deletions css/default.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
Original highlight.js style (c) Ivan Sagalaev <maniac@softwaremaniacs.org>
*/

.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
background: #F0F0F0;
}


/* Base color: saturation 0; */

.hljs,
.hljs-subst {
color: #444;
}

.hljs-comment {
color: #888888;
}

.hljs-keyword,
.hljs-attribute,
.hljs-selector-tag,
.hljs-meta-keyword,
.hljs-doctag,
.hljs-name {
font-weight: bold;
}


/* User color: hue: 0 */

.hljs-type,
.hljs-string,
.hljs-number,
.hljs-selector-id,
.hljs-selector-class,
.hljs-quote,
.hljs-template-tag,
.hljs-deletion {
color: #880000;
}

.hljs-title,
.hljs-section {
color: #880000;
font-weight: bold;
}

.hljs-regexp,
.hljs-symbol,
.hljs-variable,
.hljs-template-variable,
.hljs-link,
.hljs-selector-attr,
.hljs-selector-pseudo {
color: #BC6060;
}


/* Language color: hue: 90; */

.hljs-literal {
color: #78A960;
}

.hljs-built_in,
.hljs-bullet,
.hljs-code,
.hljs-addition {
color: #397300;
}


/* Meta color: hue: 200 */

.hljs-meta {
color: #1f7199;
}

.hljs-meta-string {
color: #4d99bf;
}


/* Misc effects */

.hljs-emphasis {
font-style: italic;
}

.hljs-strong {
font-weight: bold;
}
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<link rel="stylesheet" href="css/base16-dark.css">
<link rel="stylesheet" href="css/font-awesome.min.css">
<link rel="stylesheet" href="css/dialog.css">
<link rel="stylesheet" href="css/default.css">
</head>
<body class="container-fluid">
<div class="optContainer">
Expand Down
17 changes: 16 additions & 1 deletion js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,23 @@ $(function() {
//yourTextarea.value = cMirror.getValue();
var markdownText = cMirror.getValue();

marked.setOptions({
highlight: function (code) {
return require('highlightjs').highlightAuto(code).value;
}
});

//Md -> Preview
html = marked(markdownText,{gfm: true});
html = marked(markdownText,{
gfm: true,
tables: true,
breaks: false,
pedantic: false,
sanitize: false,
smartLists: true,
smartypants: false
});

markdownArea.innerHTML = replaceWithEmojis(html);

//Md -> HTML
Expand Down
2 changes: 1 addition & 1 deletion js/libs/marked.min.js

Large diffs are not rendered by default.

10 changes: 2 additions & 8 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
'use strict';

const electron = require('electron');
// Module to control application life.
const app = electron.app;
// Module to create native browser window.
const BrowserWindow = electron.BrowserWindow;
const {app, Menu, dialog, shell, BrowserWindow} = require('electron');

const mainPage = 'file://' + __dirname + '/index.html';
var Menu = require('menu');
var dialog = require('dialog');
var shell = require('shell');

const tray = require('./tray');
const Config = require('./package.json');
var localShortcut = require('electron-localshortcut');
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "electron-markdownify",
"version": "1.1.6",
"version": "1.2.0",
"description": "A minimalist Markdown Editor",
"main": "main.js",
"productName": "Markdownify",
Expand Down Expand Up @@ -37,13 +37,14 @@
"devDependencies": {
"devtron": "^1.1.2",
"electron-packager": "^7.0.3",
"electron-prebuilt": "^0.36.12",
"electron": "^1.4.1",
"gulp": "^3.9.1"
},
"dependencies": {
"electron-editor-context-menu": "^1.1.1",
"electron-json-storage": "latest",
"electron-localshortcut": "^1.0.0",
"highlightjs": "^9.8.0",
"parse-filepath": "latest",
"showdown": "^1.3.0"
}
Expand Down

0 comments on commit 4db8164

Please sign in to comment.