Skip to content

Commit

Permalink
Handle meta hashes on inline elements
Browse files Browse the repository at this point in the history
  • Loading branch information
evilstreak committed Jan 20, 2010
1 parent 4a8513a commit b214001
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions lib/markdown.js
Expand Up @@ -1019,6 +1019,40 @@ Markdown.dialects.Maruku.block.block_meta = function block_meta( block, next ) {
return result; return result;
} }


Markdown.dialects.Maruku.inline[ "{:" ] = function inline_meta( text, matches, out ) {
// get the preceeding element
if ( !out.length ) return [ 2 ];
var before = out[ out.length - 1 ];

if ( typeof before === "string" ) {
return [ 2, "{:" ];
}

// match a meta hash
var m = text.match( /^\{:\s+((?:\\\}|[^\}])*)\s*\}/ );

// no match, false alarm
if ( !m ) {
return [ 2, "{:" ];
}

// attach the attributes to the preceeding element
var meta = process_meta_hash( m[ 1 ] ),
attr = extract_attr( before );

if ( !attr ) {
attr = {};
before.splice( 1, 0, attr );
}

for ( var k in meta ) {
attr[ k ] = meta[ k ];
}

// cut out the string and replace it with nothing
return [ m[ 0 ].length, "" ];
}

Markdown.buildBlockOrder ( Markdown.dialects.Maruku.block ); Markdown.buildBlockOrder ( Markdown.dialects.Maruku.block );
Markdown.buildInlinePatterns( Markdown.dialects.Maruku.inline ); Markdown.buildInlinePatterns( Markdown.dialects.Maruku.inline );


Expand Down

0 comments on commit b214001

Please sign in to comment.