From 17e9cfab87ceccbea91980af6fc7a83ca29d4882 Mon Sep 17 00:00:00 2001 From: Jacques Distler Date: Tue, 1 Jun 2010 01:50:19 -0500 Subject: [PATCH] IAL's for
  • elements Add a Markdown syntax for attaching attribute lists to list items (for both ordered and unordered lists). The syntax is trivial: 1. This is the first item 2. {: value="3"} We skip straight to #3 * This is an item * {: style="color:red"} This is a red item --- .../maruku/lib/maruku/input/parse_block.rb | 6 ++++-- vendor/plugins/maruku/lib/maruku/string_utils.rb | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/vendor/plugins/maruku/lib/maruku/input/parse_block.rb b/vendor/plugins/maruku/lib/maruku/input/parse_block.rb index e29c8488..e08cb708 100644 --- a/vendor/plugins/maruku/lib/maruku/input/parse_block.rb +++ b/vendor/plugins/maruku/lib/maruku/input/parse_block.rb @@ -251,6 +251,7 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser "I see that #{h.rest.inspect} is left after the raw HTML.", src end raw_html = h.stuff_you_read + return md_html(raw_html) end @@ -283,7 +284,8 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser item_type = src.cur_line.md_type first = src.shift_line - indentation = spaces_before_first_char(first) + indentation, ial = spaces_before_first_char(first) + al = read_attribute_list(CharSource.new(ial,src), context=nil, break_on=[nil]) if ial break_list = [:ulist, :olist, :ial] # Ugly things going on inside `read_indented_content` lines, want_my_paragraph = @@ -300,7 +302,7 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser children = parse_blocks(src2) with_par = want_my_paragraph || (children.size>1) - return md_li(children, with_par) + return md_li(children, with_par, al) end def read_abbreviation(src) diff --git a/vendor/plugins/maruku/lib/maruku/string_utils.rb b/vendor/plugins/maruku/lib/maruku/string_utils.rb index e58f715a..831666b3 100644 --- a/vendor/plugins/maruku/lib/maruku/string_utils.rb +++ b/vendor/plugins/maruku/lib/maruku/string_utils.rb @@ -113,9 +113,14 @@ module MaRuKu; module Strings while s[i,1] =~ /\s/; i+=1 end # skip indicator (+, -, *) i+=1 + # skip whitespace + while s[i,1] =~ /\s/; i+=1 end + # find an IAL + ial = s[i,s.length - i][/^\{(.*?)\}/] + i+= ial.length if ial # skip optional whitespace while s[i,1] =~ /\s/; i+=1 end - return i + return [i, ial] when :olist i=0; # skip whitespace @@ -124,12 +129,17 @@ module MaRuKu; module Strings while s[i,1] =~ /\d/; i+=1 end # skip dot i+=1 + # skip optional whitespace + while s[i,1] =~ /\s/; i+=1 end + # find an IAL + ial = s[i,s.length - i][/^\{(.*?)\}/] + i+= ial.length if ial # skip whitespace while s[i,1] =~ /\s/; i+=1 end - return i + return [i, ial] else tell_user "BUG (my bad): '#{s}' is not a list" - 0 + [0, nil] end end