[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[ANN] markup_validity 1.0.0 Released

Aaron Patterson

6/13/2009 12:30:00 AM

markup_validity version 1.0.0 has been released!

* <http://github.com/tenderlove/markup_va...

MarkupValidity provides test/unit and rspec helpers for checking the validity
of your documents. Shortcuts for verifying xhtml-transitional and
xhtml-strict documents are provided as well. MarkupValidity will not only
tell you when your document is invalid, but it will tell you what it *should*
be.

Changes:

### 1.0.0 / 2009-06-11

* 1 major enhancement

* Birthday!

## FEATURES/PROBLEMS:

* Make sure that markup_validity is required *after* test/unit, or mix
MarkupValidity::Assertions in to your test class yourself.
* Currently AWESOME!

## SYNOPSIS:

###
# test/unit example
require 'test/unit'
require 'rubygems'
require 'markup_validity'

class ValidHTML < Test::Unit::TestCase
def test_i_can_has_valid_xhtml
assert_xhtml_transitional xhtml_document
end
end

###
# rspec example
require 'rubygems'
require 'markup_validity'

describe "my XHTML document" do
it "can has transitional xhtml" do
xhtml_document.should be_xhtml_transitional
end
end

###
# Rails controller test example
require 'test_helper'
require 'markup_validity'

class AwesomeControllerTest < ActionController::TestCase
test "valid markup" do
get :new
assert_xhtml_transitional @response.body
end
end

###
# Here is an example error report

Error on line: 7:
Element 'p': This element is not expected. Expected is one of ( a, br, span, bdo, object, applet, img, map, iframe, tt ).

6: <p>
7: <p>
8: Yo dawg, I heard you like p-tags
9: </p>
10: </p>
.
<false> is not true.

## REQUIREMENTS:

* depends on nokogiri

## INSTALL:

* gem install markup_validity

* <http://github.com/tenderlove/markup_va...

--
Aaron Patterson
http://tenderlovem...

7 Answers

Chrononaut

6/13/2009 5:01:00 PM

0

> markup_validity version 1.0.0 has been released!
>
> * <http://github.com/tenderlove/markup_va...
>
> MarkupValidity provides test/unit and rspec helpers for checking the validity
> of your documents. Shortcuts for verifying xhtml-transitional and
> xhtml-strict documents are provided as well. MarkupValidity will not only
> tell you when your document is invalid, but it will tell you what it *should*
> be.
>
> Changes:
>
> ### 1.0.0 / 2009-06-11
>
> * 1 major enhancement
>
> * Birthday!
>
> ## FEATURES/PROBLEMS:
>
> * Make sure that markup_validity is required *after* test/unit, or mix
> MarkupValidity::Assertions in to your test class yourself.
> * Currently AWESOME!
>
> ## SYNOPSIS:
>
> ###
> # test/unit example
> require 'test/unit'
> require 'rubygems'
> require 'markup_validity'
>
> class ValidHTML < Test::Unit::TestCase
> def test_i_can_has_valid_xhtml
> assert_xhtml_transitional xhtml_document
> end
> end
>
> ###
> # rspec example
> require 'rubygems'
> require 'markup_validity'
>
> describe "my XHTML document" do
> it "can has transitional xhtml" do
> xhtml_document.should be_xhtml_transitional
> end
> end
>
> ###
> # Rails controller test example
> require 'test_helper'
> require 'markup_validity'
>
> class AwesomeControllerTest < ActionController::TestCase
> test "valid markup" do
> get :new
> assert_xhtml_transitional @response.body
> end
> end
>
> ###
> # Here is an example error report
>
> Error on line: 7:
> Element 'p': This element is not expected. Expected is one of ( a, br, span, bdo, object, applet, img, map, iframe, tt ).
>
> 6: <p>
> 7: <p>
> 8: Yo dawg, I heard you like p-tags
> 9: </p>
> 10: </p>
> .
> <false> is not true.
>
> ## REQUIREMENTS:
>
> * depends on nokogiri
>
> ## INSTALL:
>
> * gem install markup_validity
>
> * <http://github.com/tenderlove/markup_va...
>
> --
> Aaron Pattersonhttp://tenderlovem...

Thanks for this nice gem! I've started using it on a site, but I ran
into problems with pages containing HTML entities. My workaround is
described here: http://chrononaut.net/2009/06/13/markup_validity_and_ent...

-Bjørn

Aaron Patterson

6/13/2009 5:11:00 PM

0

On Sun, Jun 14, 2009 at 02:05:07AM +0900, Bjørn Arild Mæland wrote:
> > markup_validity version 1.0.0 has been released!
> >
> > * <http://github.com/tenderlove/markup_va...
> >
> > MarkupValidity provides test/unit and rspec helpers for checking the validity
> > of your documents. Shortcuts for verifying xhtml-transitional and
> > xhtml-strict documents are provided as well. MarkupValidity will not only
> > tell you when your document is invalid, but it will tell you what it *should*
> > be.
> >
> > Changes:
> >
> > ### 1.0.0 / 2009-06-11
> >
> > * 1 major enhancement
> >
> > * Birthday!
> >
> > ## FEATURES/PROBLEMS:
> >
> > * Make sure that markup_validity is required *after* test/unit, or mix
> > MarkupValidity::Assertions in to your test class yourself.
> > * Currently AWESOME!
> >
> > ## SYNOPSIS:
> >
> > ###
> > # test/unit example
> > require 'test/unit'
> > require 'rubygems'
> > require 'markup_validity'
> >
> > class ValidHTML < Test::Unit::TestCase
> > def test_i_can_has_valid_xhtml
> > assert_xhtml_transitional xhtml_document
> > end
> > end
> >
> > ###
> > # rspec example
> > require 'rubygems'
> > require 'markup_validity'
> >
> > describe "my XHTML document" do
> > it "can has transitional xhtml" do
> > xhtml_document.should be_xhtml_transitional
> > end
> > end
> >
> > ###
> > # Rails controller test example
> > require 'test_helper'
> > require 'markup_validity'
> >
> > class AwesomeControllerTest < ActionController::TestCase
> > test "valid markup" do
> > get :new
> > assert_xhtml_transitional @response.body
> > end
> > end
> >
> > ###
> > # Here is an example error report
> >
> > Error on line: 7:
> > Element 'p': This element is not expected. Expected is one of ( a, br, span, bdo, object, applet, img, map, iframe, tt ).
> >
> > 6: <p>
> > 7: <p>
> > 8: Yo dawg, I heard you like p-tags
> > 9: </p>
> > 10: </p>
> > .
> > <false> is not true.
> >
> > ## REQUIREMENTS:
> >
> > * depends on nokogiri
> >
> > ## INSTALL:
> >
> > * gem install markup_validity
> >
> > * <http://github.com/tenderlove/markup_va...
> >
> > --
> > Aaron Pattersonhttp://tenderlovem...
>
> Thanks for this nice gem! I've started using it on a site, but I ran
> into problems with pages containing HTML entities. My workaround is
> described here: http://chrononaut.net/2009/06/13/markup_validity_and_ent...

Interesting. Thanks! I'll see if I can fix this in the gem.

--
Aaron Patterson
http://tenderlovem...

Aaron Patterson

6/13/2009 7:19:00 PM

0

On Sun, Jun 14, 2009 at 02:05:07AM +0900, Bjørn Arild Mæland wrote:
> > markup_validity version 1.0.0 has been released!
> >
> > * <http://github.com/tenderlove/markup_va...
> >
> > MarkupValidity provides test/unit and rspec helpers for checking the validity
> > of your documents. Shortcuts for verifying xhtml-transitional and
> > xhtml-strict documents are provided as well. MarkupValidity will not only
> > tell you when your document is invalid, but it will tell you what it *should*
> > be.
> >
> > Changes:
> >
> > ### 1.0.0 / 2009-06-11
> >
> > * 1 major enhancement
> >
> > * Birthday!
> >
> > ## FEATURES/PROBLEMS:
> >
> > * Make sure that markup_validity is required *after* test/unit, or mix
> > MarkupValidity::Assertions in to your test class yourself.
> > * Currently AWESOME!
> >
> > ## SYNOPSIS:
> >
> > ###
> > # test/unit example
> > require 'test/unit'
> > require 'rubygems'
> > require 'markup_validity'
> >
> > class ValidHTML < Test::Unit::TestCase
> > def test_i_can_has_valid_xhtml
> > assert_xhtml_transitional xhtml_document
> > end
> > end
> >
> > ###
> > # rspec example
> > require 'rubygems'
> > require 'markup_validity'
> >
> > describe "my XHTML document" do
> > it "can has transitional xhtml" do
> > xhtml_document.should be_xhtml_transitional
> > end
> > end
> >
> > ###
> > # Rails controller test example
> > require 'test_helper'
> > require 'markup_validity'
> >
> > class AwesomeControllerTest < ActionController::TestCase
> > test "valid markup" do
> > get :new
> > assert_xhtml_transitional @response.body
> > end
> > end
> >
> > ###
> > # Here is an example error report
> >
> > Error on line: 7:
> > Element 'p': This element is not expected. Expected is one of ( a, br, span, bdo, object, applet, img, map, iframe, tt ).
> >
> > 6: <p>
> > 7: <p>
> > 8: Yo dawg, I heard you like p-tags
> > 9: </p>
> > 10: </p>
> > .
> > <false> is not true.
> >
> > ## REQUIREMENTS:
> >
> > * depends on nokogiri
> >
> > ## INSTALL:
> >
> > * gem install markup_validity
> >
> > * <http://github.com/tenderlove/markup_va...
> >
> > --
> > Aaron Pattersonhttp://tenderlovem...
>
> Thanks for this nice gem! I've started using it on a site, but I ran
> into problems with pages containing HTML entities. My workaround is
> described here: http://chrononaut.net/2009/06/13/markup_validity_and_ent...

You wouldn't happen to have any XHTML that demonstrates the problem,
would you? I've written tests referencing entities, and it doesn't
break for me.

--
Aaron Patterson
http://tenderlovem...

Denis Defreyne

6/13/2009 10:48:00 PM

0

On 13 Jun 2009, at 02:29, Aaron Patterson wrote:

> markup_validity version 1.0.0 has been released!
>
> * <http://github.com/tenderlove/markup_va...
>
> MarkupValidity provides test/unit and rspec helpers for checking the
> validity
> of your documents. Shortcuts for verifying xhtml-transitional and
> xhtml-strict documents are provided as well. MarkupValidity will
> not only
> tell you when your document is invalid, but it will tell you what it
> *should*
> be.

Sweet! Do you plan on adding HTML support as well? I personally don't
use XHTML but I do use HTML.

Regards,

Denis

--
Denis Defreyne
denis.defreyne@stoneship.org


Rob Sanheim

6/15/2009 2:04:00 PM

0

On Fri, Jun 12, 2009 at 8:29 PM, Aaron
Patterson<aaron@tenderlovemaking.com> wrote:
> markup_validity version 1.0.0 has been released!
>
> * <http://github.com/tenderlove/markup_va...
>
> MarkupValidity provides test/unit and rspec helpers for checking the vali=
dity
> of your documents. =A0Shortcuts for verifying xhtml-transitional and
> xhtml-strict documents are provided as well. =A0MarkupValidity will not o=
nly
> tell you when your document is invalid, but it will tell you what it *sho=
uld*
> be.
>
> Changes:
>
> ### 1.0.0 / 2009-06-11
>
> * 1 major enhancement
>
> =A0* Birthday!
>
> ## FEATURES/PROBLEMS:
>
> * Make sure that markup_validity is required *after* test/unit, or mix
> =A0MarkupValidity::Assertions in to your test class yourself.
> * Currently AWESOME!
>
> ## SYNOPSIS:
>
> =A0###
> =A0# test/unit example
> =A0require 'test/unit'
> =A0require 'rubygems'
> =A0require 'markup_validity'
>
> =A0class ValidHTML < Test::Unit::TestCase
> =A0 =A0def test_i_can_has_valid_xhtml
> =A0 =A0 =A0assert_xhtml_transitional xhtml_document
> =A0 =A0end
> =A0end
>
> =A0###
> =A0# rspec example
> =A0require 'rubygems'
> =A0require 'markup_validity'
>
> =A0describe "my XHTML document" do
> =A0 =A0it "can has transitional xhtml" do
> =A0 =A0 =A0xhtml_document.should be_xhtml_transitional
> =A0 =A0end
> =A0end
>
> =A0###
> =A0# Rails controller test example
> =A0require 'test_helper'
> =A0require 'markup_validity'
>
> =A0class AwesomeControllerTest < ActionController::TestCase
> =A0 =A0test "valid markup" do
> =A0 =A0 =A0get :new
> =A0 =A0 =A0assert_xhtml_transitional @response.body
> =A0 =A0end
> =A0end
>
> =A0###
> =A0# Here is an example error report
>
> =A0Error on line: 7:
> =A0Element 'p': This element is not expected. Expected is one of ( a, br,=
span, bdo, object, applet, img, map, iframe, tt ).
>
> =A06: =A0 =A0 <p>
> =A07: =A0 =A0 =A0 <p>
> =A08: =A0 =A0 =A0 =A0 Yo dawg, I heard you like p-tags
> =A09: =A0 =A0 =A0 </p>
> =A010: =A0 =A0 </p>
> =A0.
> =A0<false> is not true.
>
> ## REQUIREMENTS:
>
> * depends on nokogiri
>
> ## INSTALL:
>
> * gem install markup_validity
>
> * <http://github.com/tenderlove/markup_va...
>
> --
> Aaron Patterson
> http://tenderlovem...

This is very cool, I'd like to integrate support for this into
Tarantula (http://github.com/relevance/tarantula/t...). How
does this compare to tidy or the w3c validator?

thanks,
Rob

Aaron Patterson

6/15/2009 5:19:00 PM

0

On Mon, Jun 15, 2009 at 11:04:00PM +0900, Rob Sanheim wrote:
> On Fri, Jun 12, 2009 at 8:29 PM, Aaron
> Patterson<aaron@tenderlovemaking.com> wrote:
> > markup_validity version 1.0.0 has been released!
> >
> > * <http://github.com/tenderlove/markup_va...
> >
> > MarkupValidity provides test/unit and rspec helpers for checking the validity
> > of your documents.  Shortcuts for verifying xhtml-transitional and
> > xhtml-strict documents are provided as well.  MarkupValidity will not only
> > tell you when your document is invalid, but it will tell you what it *should*
> > be.
> >
> > Changes:
> >
> > ### 1.0.0 / 2009-06-11
> >
> > * 1 major enhancement
> >
> >  * Birthday!
> >
> > ## FEATURES/PROBLEMS:
> >
> > * Make sure that markup_validity is required *after* test/unit, or mix
> >  MarkupValidity::Assertions in to your test class yourself.
> > * Currently AWESOME!
> >
> > ## SYNOPSIS:
> >
> >  ###
> >  # test/unit example
> >  require 'test/unit'
> >  require 'rubygems'
> >  require 'markup_validity'
> >
> >  class ValidHTML < Test::Unit::TestCase
> >    def test_i_can_has_valid_xhtml
> >      assert_xhtml_transitional xhtml_document
> >    end
> >  end
> >
> >  ###
> >  # rspec example
> >  require 'rubygems'
> >  require 'markup_validity'
> >
> >  describe "my XHTML document" do
> >    it "can has transitional xhtml" do
> >      xhtml_document.should be_xhtml_transitional
> >    end
> >  end
> >
> >  ###
> >  # Rails controller test example
> >  require 'test_helper'
> >  require 'markup_validity'
> >
> >  class AwesomeControllerTest < ActionController::TestCase
> >    test "valid markup" do
> >      get :new
> >      assert_xhtml_transitional @response.body
> >    end
> >  end
> >
> >  ###
> >  # Here is an example error report
> >
> >  Error on line: 7:
> >  Element 'p': This element is not expected. Expected is one of ( a, br, span, bdo, object, applet, img, map, iframe, tt ).
> >
> >  6:     <p>
> >  7:       <p>
> >  8:         Yo dawg, I heard you like p-tags
> >  9:       </p>
> >  10:     </p>
> >  .
> >  <false> is not true.
> >
> > ## REQUIREMENTS:
> >
> > * depends on nokogiri
> >
> > ## INSTALL:
> >
> > * gem install markup_validity
> >
> > * <http://github.com/tenderlove/markup_va...
> >
> > --
> > Aaron Patterson
> > http://tenderlovem...
>
> This is very cool, I'd like to integrate support for this into
> Tarantula (http://github.com/relevance/tarantula/t...). How
> does this compare to tidy or the w3c validator?

I encourage you to do a comparison, but this is what I found in my small
tests:

MarkupValidity does not complain about missing doctypes (I should
probably make it do that). MarkupValidity reports the same errors that
the w3c validator does, but (IMHO) MarkupValidity's error messages are
slightly better. Plus you don't need to hit the network when using
MarkupValidity.

Tidy actually corrects your document, and I think sometimes the errors
and warnings reported are unclear. For example, this document:

<html xmlns="http://www.w3.org/1999/xhtml...
<head></head>
<body>
<p><p>Hello</p></p>
</body>
</html>

Give you these errors from tidy:

line 1 column 1 - Warning: missing <!DOCTYPE> declaration
line 9 column 5 - Warning: inserting implicit <p>
line 2 column 3 - Warning: inserting missing 'title' element
line 5 column 5 - Warning: trimming empty <p>
line 9 column 5 - Warning: trimming empty <p>
5 warnings, 0 errors were found!

MarkupValidity says this:

Error on line: 2:
Element 'head': Missing child element(s). Expected is one of ( script, style, meta, link, object, isindex, title, base ).

1: <html xmlns="http://www.w3.org/1999/xhtml...
2: <head>
3: </head>
4: <body>
5: <p>

Error on line: 6:
Element 'p': This element is not expected. Expected is one of ( a, br, span, bdo, object, applet, img, map, iframe, tt ).

5: <p>
6: <p>
7: Hello
8: </p>
9: </p>

When I'm testing my documents, I don't want them corrected. *I* want to do the
corrections. If the document needs to be corrected, then something is wrong.

I'm not sure about speed. I suspect that MarkupValidity will be faster
since it is not doing any document corrections. But that doesn't really
matter to me. The error messages are what make my life easy.

--
Aaron Patterson
http://tenderlovem...

Aaron Patterson

6/15/2009 6:05:00 PM

0

On Sun, Jun 14, 2009 at 07:47:34AM +0900, Denis Defreyne wrote:
> On 13 Jun 2009, at 02:29, Aaron Patterson wrote:
>
>> markup_validity version 1.0.0 has been released!
>>
>> * <http://github.com/tenderlove/markup_va...
>>
>> MarkupValidity provides test/unit and rspec helpers for checking the
>> validity
>> of your documents. Shortcuts for verifying xhtml-transitional and
>> xhtml-strict documents are provided as well. MarkupValidity will not
>> only
>> tell you when your document is invalid, but it will tell you what it
>> *should*
>> be.
>
> Sweet! Do you plan on adding HTML support as well? I personally don't
> use XHTML but I do use HTML.

Possibly. This project uses schemas to validate the XHTML. I could not
find any schemas for HTML, and I don't want to deal with DTD validation.

I might add something, but it isn't really high on my priority list
since I only use XHTML.

--
Aaron Patterson
http://tenderlovem...