aboutsummaryrefslogtreecommitdiff
path: root/plugin/markdown
diff options
context:
space:
mode:
authorHakim El Hattab <hakim.elhattab@gmail.com>2013-10-28 09:06:43 -0400
committerHakim El Hattab <hakim.elhattab@gmail.com>2013-10-28 09:06:43 -0400
commitd844195be137d6e67fd7eace5ad4d5f1310e7401 (patch)
tree0f08c7fe2e7a5472b992394a5cd89ae26be7ff73 /plugin/markdown
parent6cf5269bfc8ce9633efdfba453e20ced27c4f254 (diff)
downloadfreenode-live-2017-presentation-d844195be137d6e67fd7eace5ad4d5f1310e7401.tar
freenode-live-2017-presentation-d844195be137d6e67fd7eace5ad4d5f1310e7401.tar.gz
format tweaks markdown.js, remove extra image asset
Diffstat (limited to 'plugin/markdown')
-rwxr-xr-xplugin/markdown/markdown.js30
1 files changed, 17 insertions, 13 deletions
diff --git a/plugin/markdown/markdown.js b/plugin/markdown/markdown.js
index fccc442..d6c6c45 100755
--- a/plugin/markdown/markdown.js
+++ b/plugin/markdown/markdown.js
@@ -28,7 +28,7 @@
var DEFAULT_SLIDE_SEPARATOR = '^\n---\n$',
DEFAULT_NOTES_SEPARATOR = 'note:';
- DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR = '{\\\.\s*?([^}]+?)}';
+ DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR = '{_\s*?([^}]+?)}';
/**
@@ -277,46 +277,50 @@
* directly on refresh (F5)
* http://stackoverflow.com/questions/5690269/disabling-chrome-cache-for-website-development/7000899#answer-11786277
*/
- function addAttributeInElement( node, elementTarget, separator ){
+ function addAttributeInElement( node, elementTarget, separator ) {
+
var mardownClassesInElementsRegex = new RegExp( separator, 'mg' );
var mardownClassRegex = new RegExp( "([^\"= ]+?)=\"([^\"=]+?)\"", 'mg' );
var nodeValue = node.nodeValue;
- if ( matches = mardownClassesInElementsRegex.exec( nodeValue ) ) {
+ if( matches = mardownClassesInElementsRegex.exec( nodeValue ) ) {
var classes = matches[1];
nodeValue = nodeValue.substring( 0, matches.index ) + nodeValue.substring( mardownClassesInElementsRegex.lastIndex );
node.nodeValue = nodeValue;
while( matchesClass = mardownClassRegex.exec( classes ) ) {
- elementTarget.setAttribute(matchesClass[1], matchesClass[2]);
+ elementTarget.setAttribute( matchesClass[1], matchesClass[2] );
}
}
+
}
/**
* Add attributes to the parent element of a text node,
* or the element of an attribute node.
*/
- function addAttributes( element, separator )
- {
- if ( element.childNodes.length > 0 ) {
+ function addAttributes( element, separator ) {
- for ( var i = 0; i < element.childNodes.length; i++ ) {
+ if( element.childNodes.length > 0 ) {
+ for( var i = 0; i < element.childNodes.length; i++ ) {
addAttributes( element.childNodes[i], separator );
}
}
+
var nodeValue;
var elementTarget;
+
// From http://stackoverflow.com/questions/9178174/find-all-text-nodes
- if ( element.nodeType == Node.TEXT_NODE && /\S/.test(element.nodeValue) ) {
+ if( element.nodeType == Node.TEXT_NODE && /\S/.test(element.nodeValue) ) {
addAttributeInElement( element, element.parentNode, separator );
}
- if ( element.nodeType == Node.ELEMENT_NODE && element.attributes.length > 0 ) {
- for ( iattr=0; iattr<element.attributes.length; iattr++ ){
- var attr = element.attributes[iattr];
- addAttributeInElement(attr, element, separator )
+ if( element.nodeType == Node.ELEMENT_NODE && element.attributes.length > 0 ) {
+ for( var j = 0; j < element.attributes.length; j++ ){
+ var attr = element.attributes[j];
+ addAttributeInElement( attr, element, separator );
}
}
+
}
/**