Browse Source

Added strict commonmark option to demo

pull/14/head
Vitaly Puzrin 10 years ago
parent
commit
f17ce5a663
  1. 19
      demo/assets/index.js
  2. 5
      demo/assets/index.styl
  3. 18
      demo/index.jade

19
demo/assets/index.js

@ -13,6 +13,7 @@
// options below are for demo only // options below are for demo only
_highlight: false, _highlight: false,
_strict: false,
_src: false _src: false
}; };
@ -32,9 +33,18 @@
return ''; return '';
}; };
function setOptionClass(name, val) {
if (val) {
$('body').addClass('opt_' + name);
} else {
$('body').removeClass('opt_' + name);
}
}
function mdInit() { function mdInit() {
mdHtml = new window.Remarkable(defaults); var opts = defaults._strict ? 'commonmark' : defaults;
mdSrc = new window.Remarkable(defaults); mdHtml = new window.Remarkable(opts);
mdSrc = new window.Remarkable(opts);
// Beautify output of parser for html content // Beautify output of parser for html content
mdHtml.renderer.rules.table_open = function () { mdHtml.renderer.rules.table_open = function () {
@ -108,10 +118,13 @@
if (_.isBoolean(val)) { if (_.isBoolean(val)) {
$el.prop('checked', val); $el.prop('checked', val);
$el.on('change', function () { $el.on('change', function () {
defaults[key] = Boolean($el.prop('checked')); var value = Boolean($el.prop('checked'));
setOptionClass(key, value);
defaults[key] = value;
mdInit(); mdInit();
updateResult(); updateResult();
}); });
setOptionClass(key, val);
} else { } else {
$(el).val(val); $(el).val(val);

5
demo/assets/index.styl

@ -9,6 +9,9 @@ body
.demo-options .demo-options
margin-bottom 10px margin-bottom 10px
.opt__strict .not-strict
opacity 0.5
.checkbox .checkbox
margin-right 10px margin-right 10px
@ -21,7 +24,7 @@ body
padding-right 20px padding-right 20px
overflow auto overflow auto
img img
max-width 100% max-width 50%
.result-src .result-src
display none display none

18
demo/index.jade

@ -28,36 +28,40 @@ html
code.js= s.code code.js= s.code
.form-inline.demo-options .form-inline.demo-options
.checkbox .checkbox.not-strict
label._tip(title='enable html tags in source text') label._tip(title='enable html tags in source text')
input#html(type='checkbox') input#html(type='checkbox')
| html | html
.checkbox .checkbox.not-strict
label._tip(title='produce xtml output (add / to single tags (<br /> instead of <br>)') label._tip(title='produce xtml output (add / to single tags (<br /> instead of <br>)')
input#xhtmlOut(type='checkbox') input#xhtmlOut(type='checkbox')
| xhtmlOut | xhtmlOut
.checkbox .checkbox.not-strict
label._tip(title='newlines in paragraphs are rendered as <br>') label._tip(title='newlines in paragraphs are rendered as <br>')
input#breaks(type='checkbox') input#breaks(type='checkbox')
| breaks | breaks
.checkbox .checkbox.not-strict
label._tip(title='autoconvert link-like texts to links') label._tip(title='autoconvert link-like texts to links')
input#linkify(type='checkbox') input#linkify(type='checkbox')
| linkify | linkify
.checkbox .checkbox.not-strict
label._tip(title='do typographyc replacements, (c) -> © and so on') label._tip(title='do typographyc replacements, (c) -> © and so on')
input#typographer(type='checkbox') input#typographer(type='checkbox')
| typographer | typographer
.checkbox .checkbox.not-strict
label._tip(title='enable output highlight for fenced blocks') label._tip(title='enable output highlight for fenced blocks')
input#_highlight(type='checkbox') input#_highlight(type='checkbox')
| highlight | highlight
.form-group .form-group.not-strict
input#langPrefix.form-control._tip( input#langPrefix.form-control._tip(
type='input' type='input'
placeholder='language prefix' placeholder='language prefix'
title='css class language prefix for fenced code blocks' title='css class language prefix for fenced code blocks'
) )
.checkbox
label._tip(title='force strict CommonMark mode - output will be equal to reference parser')
input#_strict(type='checkbox')
| CommonMark strict
.container.full-height .container.full-height
.row.full-height .row.full-height

Loading…
Cancel
Save