Add markdown dialect attribute. (#763)

Resolves #724
This commit is contained in:
Mohamed Feddad
2020-04-01 10:08:27 +03:00
committed by GitHub
parent ef57b5b471
commit 203b85808c
4 changed files with 15 additions and 2 deletions

View File

@@ -120,6 +120,11 @@ are converted to HTML first, then colored by Highlight.js:
the content was written in simple Markdown. the content was written in simple Markdown.
</div> </div>
<div class="step slide title markdown" data-rotate="-85" data-x="4000" data-y="2000" data-markdown-dialect="Maruku">
This is an example of a slide with a specific Markdown dialect.
===============================================================
</div>
<script type="text/javascript"> <script type="text/javascript">
var enableBwCss = function(){ var enableBwCss = function(){
disableDevopsCss(); disableDevopsCss();

View File

@@ -1566,10 +1566,11 @@
var markdownDivs = document.querySelectorAll( ".markdown" ); var markdownDivs = document.querySelectorAll( ".markdown" );
for ( var idx = 0; idx < markdownDivs.length; idx++ ) { for ( var idx = 0; idx < markdownDivs.length; idx++ ) {
var element = markdownDivs[ idx ]; var element = markdownDivs[ idx ];
var dialect = element.dataset.markdownDialect;
var slides = element.textContent.split( /^-----$/m ); var slides = element.textContent.split( /^-----$/m );
var i = slides.length - 1; var i = slides.length - 1;
element.innerHTML = markdown.toHTML( slides[ i ] ); element.innerHTML = markdown.toHTML( slides[ i ], dialect );
// If there's an id, unset it for last, and all other, elements, // If there's an id, unset it for last, and all other, elements,
// and then set it for the first. // and then set it for the first.

View File

@@ -40,6 +40,12 @@ HTML and CSS that you can use with that plugin.
For your convenience, below is some sample HTML and CSS code covering all the For your convenience, below is some sample HTML and CSS code covering all the
plugins that you may want to use or adapt. plugins that you may want to use or adapt.
Additional parameters for addons
--------------------------------
Some addons can handle additional HTML data attributes to help us in further customization:
- Markdown-JS: You can pass a specific Markdown dialect to the plugin using `data-markdown-dialect="Another Dialect"`.
### Sample HTML to enable plugins and extra addons ### Sample HTML to enable plugins and extra addons
<head> <head>

View File

@@ -25,10 +25,11 @@
var markdownDivs = document.querySelectorAll( ".markdown" ); var markdownDivs = document.querySelectorAll( ".markdown" );
for ( var idx = 0; idx < markdownDivs.length; idx++ ) { for ( var idx = 0; idx < markdownDivs.length; idx++ ) {
var element = markdownDivs[ idx ]; var element = markdownDivs[ idx ];
var dialect = element.dataset.markdownDialect;
var slides = element.textContent.split( /^-----$/m ); var slides = element.textContent.split( /^-----$/m );
var i = slides.length - 1; var i = slides.length - 1;
element.innerHTML = markdown.toHTML( slides[ i ] ); element.innerHTML = markdown.toHTML( slides[ i ], dialect );
// If there's an id, unset it for last, and all other, elements, // If there's an id, unset it for last, and all other, elements,
// and then set it for the first. // and then set it for the first.