~ubuntu-branches/ubuntu/quantal/tidy/quantal

« back to all changes in this revision

Viewing changes to src/clean.c

  • Committer: Bazaar Package Importer
  • Author(s): Jason Thomas
  • Date: 2008-12-24 13:25:54 UTC
  • mfrom: (3.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20081224132554-l7900667kdy9eeu5
Tags: 20081224cvs-1
* New cvs snapshot
* debian/control: add debhelper ${misc:Depends} to all packages
- add versioned depend on libtidy-0.99-0 (>= 20081224cvs-1) for tidy
  (closes: #470764)
- add Homepage field
- update standards-version from 3.7.3.0 to 3.8.0.0
* debian/tidy-doc.doc-base: change section from App/Text to Web Development
* debian/tidy.postinst + tidy.preinst: set the -e flag
* debian/README.source: new, how to build source tarball from upstream
* debian/README.Debian: add urls to more documentation
  (closes: #353912)
* debian/patches/03overview-tab-size.patch: add patch to fix tab-size
  (closes: #353907)
* tidy doc has been built from same source as tidy for a while
  (closes: #364960)
* debian/rules:
  - add -xml-config to generated manpage
  - clean up generated files
  (closes: #471107)
* manpage: -latin0 options has correct info as of 20080116cvs-1
  (closes: #506394 )

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
  clean.c -- clean up misuse of presentation markup
3
3
 
4
 
  (c) 1998-2006 (W3C) MIT, ERCIM, Keio University
 
4
  (c) 1998-2008 (W3C) MIT, ERCIM, Keio University
5
5
  See tidy.h for the copyright notice.
6
6
 
7
7
  CVS Info :
8
8
 
9
9
    $Author: arnaud02 $ 
10
 
    $Date: 2007/08/13 16:27:26 $ 
11
 
    $Revision: 1.109 $ 
 
10
    $Date: 2008/10/14 12:18:10 $ 
 
11
    $Revision: 1.111 $ 
12
12
 
13
13
  Filters from other formats such as Microsoft Word
14
14
  often make excessive use of presentation markup such
1691
1691
          }
1692
1692
        }
1693
1693
 
1694
 
        /* discard node and returns next */
1695
 
        node = TY_(DiscardElement)( doc, node );
 
1694
        /* discard node and returns next, unless it is a text node */
 
1695
        if ( node->type == TextNode )
 
1696
            node = node->next;
 
1697
        else
 
1698
            node = TY_(DiscardElement)( doc, node );
1696
1699
 
1697
1700
        if (node == NULL)
1698
1701
            return NULL;
2598
2601
        {
2599
2602
            AttVal *name = TY_(AttrGetById)(node, TidyAttr_NAME);
2600
2603
            AttVal *id = TY_(AttrGetById)(node, TidyAttr_ID);
 
2604
            Bool hadName = name!=NULL;
 
2605
            Bool hadId = id!=NULL;
 
2606
            Bool IdEmitted = no;
 
2607
            Bool NameEmitted = no;
2601
2608
 
2602
2609
            /* todo: how are empty name/id attributes handled? */
2603
2610
 
2618
2625
                    if (TY_(IsValidHTMLID)(name->value))
2619
2626
                    {
2620
2627
                        TY_(RepairAttrValue)(doc, node, "id", name->value);
 
2628
                        IdEmitted = yes;
2621
2629
                    }
2622
2630
                    else
2623
 
                    {
2624
2631
                        TY_(ReportAttrError)(doc, node, name, INVALID_XML_ID);
2625
 
                    }
2626
2632
                 }
2627
2633
            }
2628
2634
            else if (id && wantName)
2629
2635
            {
2630
2636
                if (TY_(NodeAttributeVersions)( node, TidyAttr_NAME )
2631
2637
                    & doc->lexer->versionEmitted)
 
2638
                {
2632
2639
                    /* todo: do not assume id is valid */
2633
2640
                    TY_(RepairAttrValue)(doc, node, "name", id->value);
 
2641
                    NameEmitted = yes;
 
2642
                }
2634
2643
            }
2635
2644
 
2636
 
            if (id && !wantId)
 
2645
            if (id && !wantId
 
2646
                /* make sure that Name has been emitted if requested */
 
2647
                && (hadName || !wantName || NameEmitted) )
2637
2648
                TY_(RemoveAttribute)(doc, node, id);
2638
 
            
2639
 
            if (name && !wantName)
 
2649
 
 
2650
            if (name && !wantName
 
2651
                /* make sure that Id has been emitted if requested */
 
2652
                && (hadId || !wantId || IdEmitted) )
2640
2653
                TY_(RemoveAttribute)(doc, node, name);
2641
2654
 
2642
2655
            if (TY_(AttrGetById)(node, TidyAttr_NAME) == NULL &&