Vitaly Puzrin
10 years ago
7 changed files with 79 additions and 87 deletions
@ -1,4 +1,3 @@ |
|||||
benchmark/implementations/ |
benchmark/implementations/ |
||||
demo/ |
|
||||
dist/ |
dist/ |
||||
node_modules/ |
node_modules/ |
||||
|
@ -0,0 +1,6 @@ |
|||||
|
env: |
||||
|
node: false |
||||
|
browser: true |
||||
|
|
||||
|
globals: |
||||
|
$: false |
@ -1,32 +1,51 @@ |
|||||
$(function() { |
(function () { |
||||
// highlight snippets
|
'use strict'; |
||||
$('pre.code-sample code').each(function(i, block) { |
|
||||
hljs.highlightBlock(block); |
var mdHtml, mdSrc; |
||||
}); |
|
||||
}); |
var options = { |
||||
|
html: true, |
||||
|
xhtml: true, |
||||
|
breaks: false, |
||||
|
langprefix: 'language-' |
||||
|
}; |
||||
|
|
||||
var md = new window.Remarkable({ |
function mdInit() { |
||||
html: true, |
mdHtml = new window.Remarkable(options); |
||||
xhtml: true, |
mdSrc = new window.Remarkable(options); |
||||
breaks: false, |
|
||||
langprefix: 'language-' |
|
||||
}); |
|
||||
|
|
||||
md.renderer.rules.table_open = function () { |
// Beautify output of parser for html content
|
||||
return '<table class="table table-striped">\n'; |
mdHtml.renderer.rules.table_open = function () { |
||||
} |
return '<table class="table table-striped">\n'; |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
function updateResult() { |
||||
|
var source = $('.source').val(); |
||||
|
$('.result').html(mdHtml.render(source)); |
||||
|
$('.result-src-content').text(mdSrc.render(source)); |
||||
|
} |
||||
|
|
||||
function updateResult() { |
|
||||
var result = md.render($('#demo1 .source').val()); |
|
||||
$('#demo1 .result').html(result); |
|
||||
$('#demo1 .result-text-data').text(result); |
|
||||
} |
|
||||
|
|
||||
$('#demo1 .source').on('keyup paste cut mouseup', updateResult); |
$(function() { |
||||
$('#demo1 .mode').on('click', function (event) { |
// highlight snippet
|
||||
$('#demo1').toggleClass('result-as-text'); |
$('pre.code-sample code').each(function(i, block) { |
||||
event.preventDefault(); |
window.hljs.highlightBlock(block); |
||||
}); |
}); |
||||
|
|
||||
updateResult(); |
mdInit(); |
||||
|
|
||||
|
$('.source').on('keyup paste cut mouseup', updateResult); |
||||
|
$('.source-clear').on('click', function (event) { |
||||
|
$('.source').val(''); |
||||
|
updateResult(); |
||||
|
event.preventDefault(); |
||||
|
}); |
||||
|
$('.result-mode').on('click', function (event) { |
||||
|
$('body').toggleClass('result-as-text'); |
||||
|
event.preventDefault(); |
||||
|
}); |
||||
|
|
||||
|
updateResult(); |
||||
|
}); |
||||
|
})(); |
||||
|
Loading…
Reference in new issue