ruby-changes:3964
From: ko1@a...
Date: Wed, 13 Feb 2008 08:59:19 +0900 (JST)
Subject: [ruby-changes:3964] drbrain - Ruby:r15454 (trunk): Allow inline markup to have a leading '#' or '\', or trailing punctuation.
drbrain 2008-02-13 08:59:03 +0900 (Wed, 13 Feb 2008)
New Revision: 15454
Modified files:
trunk/ChangeLog
trunk/lib/rdoc/markup/inline.rb
trunk/test/rdoc/test_rdoc_markup.rb
trunk/test/rdoc/test_rdoc_markup_attribute_manager.rb
Log:
Allow inline markup to have a leading '#' or '\', or trailing punctuation.
i.e. *#freeze?*, *\foo?*.
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/rdoc/test_rdoc_markup.rb?r1=15454&r2=15453&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15454&r2=15453&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/rdoc/test_rdoc_markup_attribute_manager.rb?r1=15454&r2=15453&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/rdoc/markup/inline.rb?r1=15454&r2=15453&diff_format=u
Index: ChangeLog
===================================================================
--- ChangeLog (revision 15453)
+++ ChangeLog (revision 15454)
@@ -1,3 +1,8 @@
+Wed Feb 13 08:57:21 2008 Eric Hodel <drbrain@s...>
+
+ * lib/rdoc/markup/inline.rb: Allow inline markup to have a leading
+ '#' or '\', or trailing punctuation. i.e. *#freeze?*, *\foo?*.
+
Wed Feb 13 07:21:23 2008 Eric Hodel <drbrain@s...>
* lib/rdoc/to_html_hyperlink.rb: Moved linking to to_html.rb, move
Index: lib/rdoc/markup/inline.rb
===================================================================
--- lib/rdoc/markup/inline.rb (revision 15453)
+++ lib/rdoc/markup/inline.rb (revision 15454)
@@ -167,21 +167,20 @@
# first do matching ones
tags = MATCHING_WORD_PAIRS.keys.join("")
- re = "(^|\\W)([#{tags}])([A-Za-z_]+?)\\2(\\W|\$)"
-# re = "(^|\\W)([#{tags}])(\\S+?)\\2(\\W|\$)"
+ re = /(^|\W)([#{tags}])([#\\]?[\w.\/]+?\S?)\2(\W|$)/
- 1 while str.gsub!(Regexp.new(re)) {
- attr = MATCHING_WORD_PAIRS[$2];
+ 1 while str.gsub!(re) do
+ attr = MATCHING_WORD_PAIRS[$2]
attrs.set_attrs($`.length + $1.length + $2.length, $3.length, attr)
- $1 + NULL*$2.length + $3 + NULL*$2.length + $4
- }
+ $1 + NULL * $2.length + $3 + NULL * $2.length + $4
+ end
# then non-matching
- unless WORD_PAIR_MAP.empty?
+ unless WORD_PAIR_MAP.empty? then
WORD_PAIR_MAP.each do |regexp, attr|
- str.gsub!(regexp) {
+ str.gsub!(regexp) {
attrs.set_attrs($`.length + $1.length, $2.length, attr)
- NULL*$1.length + $2 + NULL*$3.length
+ NULL * $1.length + $2 + NULL * $3.length
}
end
end
@@ -213,9 +212,8 @@
# A \ in front of a character that would normally be processed turns off
# processing. We do this by turning \< into <#{PROTECT}
- PROTECTABLE = [ "<" << "\\" ]
+ PROTECTABLE = %w[<\\]
-
def mask_protected_sequences
protect_pattern = Regexp.new("\\\\([#{Regexp.escape(PROTECTABLE.join(''))}])")
@str.gsub!(protect_pattern, "\\1#{PROTECT_ATTR}")
@@ -272,11 +270,15 @@
@attrs = AttrSpan.new(@str.length)
puts("After protecting, str='#{@str.dump}'") if $DEBUG_RDOC
+
convert_attrs(@str, @attrs)
convert_html(@str, @attrs)
convert_specials(str, @attrs)
+
unmask_protected_sequences
+
puts("After flow, str='#{@str.dump}'") if $DEBUG_RDOC
+
return split_into_flow
end
Index: test/rdoc/test_rdoc_markup_attribute_manager.rb
===================================================================
--- test/rdoc/test_rdoc_markup_attribute_manager.rb (revision 15453)
+++ test/rdoc/test_rdoc_markup_attribute_manager.rb (revision 15454)
@@ -82,6 +82,17 @@
end
+ def test_bold
+ assert_equal [@bold_on, 'bold', @bold_off],
+ @am.flow("*bold*")
+
+ assert_equal [@bold_on, 'Bold:', @bold_off],
+ @am.flow("*Bold:*")
+
+ assert_equal [@bold_on, '\\bold', @bold_off],
+ @am.flow("*\\bold*")
+ end
+
def test_combined
assert_equal(["cat ", @em_on, "and", @em_off, " ", @bold_on, "dog", @bold_off],
@am.flow("cat _and_ *dog*"))
Index: test/rdoc/test_rdoc_markup.rb
===================================================================
--- test/rdoc/test_rdoc_markup.rb (revision 15453)
+++ test/rdoc/test_rdoc_markup.rb (revision 15454)
@@ -334,6 +334,20 @@
"L1: ListEnd\n" ])
end
+ def test_list_nested_number_number
+ str = "1. one\n1. two\n 1. cat\n 1. dog"
+
+ line_groups(str,
+ [ "L1: ListStart\n",
+ "L1: NUMBER ListItem\none",
+ "L1: NUMBER ListItem\ntwo",
+ "L2: ListStart\n",
+ "L2: NUMBER ListItem\ncat",
+ "L2: NUMBER ListItem\ndog",
+ "L2: ListEnd\n",
+ "L1: ListEnd\n" ])
+ end
+
def test_list_number
str = "1. one\n2. two\n1. three"
--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/