Permalink
Browse files

Implement style blocks

  • Loading branch information...
1 parent 1675ae1 commit 486ced2027f1a61b334ff44d1c965ca0d14445e4 @drbrain drbrain committed Oct 30, 2011
Showing with 26 additions and 17 deletions.
  1. +8 −7 pegdown.kpeg
  2. +18 −10 test/test_pegdown.rb
View
@@ -28,6 +28,11 @@
RUBY
end
+ ##
+ # Allow style blocks
+
+ extension :css
+
##
# Allow HTML
@@ -492,13 +497,9 @@ StyleClose = "<" Spnl "/" ("style" | "STYLE") Spnl ">"
InStyleTags = StyleOpen (!StyleClose .)* StyleClose
StyleBlock = < InStyleTags >
BlankLine*
- { raise 'if (extension(EXT_FILTER_STYLES)) {
- $$ = mk_list(LIST, NULL);
- } else {
- $$ = mk_str(yytext);
- $$->key = HTMLBLOCK;
- }'
- }
+ { if css? then
+ RDoc::Markup::Raw.new text
+ end }
Inlines = ( !Endline Inline:i { i }
| Endline:c &Inline { c } )+:chunks Endline?
View
@@ -454,16 +454,24 @@ def test_parse_strong_underscore
assert_equal expected, doc
end
-# def test_parse_style
-# doc = parse <<-MD
-#<style></style>
-# MD
-#
-# expected = @RM::Document.new(
-# @RM::Paragraph.new("it worked"))
-#
-# assert_equal expected, doc
-# end
+ def test_parse_style
+ @parser.css = true
+
+ doc = parse "<style>h1 { color: red }</style>\n"
+
+ expected = doc(
+ @RM::Raw.new("<style>h1 { color: red }</style>"))
+
+ assert_equal expected, doc
+ end
+
+ def test_parse_style
+ doc = parse "<style>h1 { color: red }</style>\n"
+
+ expected = doc()
+
+ assert_equal expected, doc
+ end
def test_parse_verbatim
doc = parse <<-MD

0 comments on commit 486ced2

Please sign in to comment.