IAL's for <li> 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
This commit is contained in:
parent
b8647da41a
commit
17e9cfab87
|
@ -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)
|
||||
|
|
16
vendor/plugins/maruku/lib/maruku/string_utils.rb
vendored
16
vendor/plugins/maruku/lib/maruku/string_utils.rb
vendored
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue