Tools__TagList.st
branchjv
changeset 12292 ecc23f7c8dde
parent 12287 400a99059170
child 12308 5d9291c0fc27
--- a/Tools__TagList.st	Wed Sep 12 12:00:27 2012 +0100
+++ b/Tools__TagList.st	Thu Sep 13 10:15:20 2012 +0100
@@ -26,8 +26,8 @@
 		hidePythonClasses hidePythonMethods hidePythonFunctions
 		hideOzClasses hideOzMethods hideOzFunctions hideHTMLTextArea
 		hideHTMLInput hideHTMLTable hideHTMLScript hideHTMLForm
-		usingDefaultCTags ctagsCommand ctagsIsExCtags ctagsIsExCtags5x
-		hideDocumentation remoteTarget hideLocalLabels3'
+		hideHTMLHeaders usingDefaultCTags ctagsCommand ctagsIsExCtags
+		ctagsIsExCtags5x hideDocumentation remoteTarget hideLocalLabels3'
 	classVariableNames:'Sorted CachedTagListsPerFile DefaultSortCriteria DefaultShowOnly
 		TagsSuffixes DefaultGroupBy'
 	poolDictionaries:''
@@ -811,6 +811,18 @@
     "Modified: / 05-05-2011 / 15:22:18 / cg"
 !
 
+hideHTMLHeaders
+    ^ hideHTMLHeaders ? false
+
+    "Created: / 12-09-2012 / 12:29:45 / cg"
+!
+
+hideHTMLHeaders:aBoolean
+    hideHTMLHeaders := aBoolean.
+
+    "Created: / 12-09-2012 / 12:29:52 / cg"
+!
+
 hideHTMLInput
     ^ hideHTMLInput ? false
 
@@ -2613,6 +2625,7 @@
         <input>
         <table>
         <script>
+        <hX>
     "
 
     |targets line l lineNr s tag|
@@ -2637,38 +2650,72 @@
                 'table'         hideHTMLTable
                 'script'        hideHTMLScript  
                 'form'          hideHTMLForm  
+                'a'             nil  
+                'h1'            hideHTMLHeaders  
+                'h2'            hideHTMLHeaders  
+                'h3'            hideHTMLHeaders  
+                'h4'            hideHTMLHeaders  
+                'h5'            hideHTMLHeaders  
+                'h6'            hideHTMLHeaders  
             ) pairWiseDo:[:nm :hideInstVarName|
-                |type hideHolder idx tagText doc markup label|
+                |type hideHolder idx tagText doc markup label text markupName markupType
+                 isHeader|
 
                 type := hideHolder := nil.
 
                 idx := l indexOfSubCollection:('<',nm).
                 idx ~~ 0 ifTrue:[
-                    type := Tag::TElement.
-                    hideHolder := self instVarNamed:hideInstVarName.
+                    hideHolder := hideInstVarName isNil 
+                                    ifTrue:[ false ]
+                                    ifFalse:[ self instVarNamed:hideInstVarName ].
 
                     tagText := line copyFrom:idx.
                     doc := HTMLParser new parseText:tagText.
                     markup := doc markup.
+                    markupName := markup name.
+                    markupType := "markup tag ?" markup type.
+
+                    isHeader := (#(h1 h2 h3 h4 h5 h6) includes:markupType).
+                    isHeader ifTrue:[ 
+                        type := Tag::THeaderElement  
+                    ] ifFalse: [ 
+                        markupType == #'form' ifTrue:[ 
+                            type := Tag::TFormElement
+                        ] ifFalse:[
+                            markupType == #'a' ifTrue:[ 
+                                type := Tag::TAnchorElement.
+                                markupName := markup hrefString notEmptyOrNil ifTrue:['"',markup hrefString,'"'] ifFalse:[ markup name ]
+                            ] ifFalse:[ 
+                                type := Tag::TElement 
+                            ]
+                        ].
+                    ].
+
                     markup id notEmptyOrNil ifTrue:[
                         label := nm , ' (',markup id,')'
                     ] ifFalse:[
-                        markup name notEmptyOrNil ifTrue:[
-                            label := nm , ' (',markup name,')'
+                        markupName notEmptyOrNil ifTrue:[
+                            label := nm , ' (',markupName,')'
                         ] ifFalse:[
-                            (markup type == #input and:[ markup valueString notEmptyOrNil ]) ifTrue:[
-                                label := nm , ' (',markup valueString,')'
+                            (markupType == #input and:[ markup valueString notEmptyOrNil ]) ifTrue:[
+                                label := nm , ' ("',markup valueString,'")'
                             ] ifFalse:[
-                                (markup type == #script and:[ markup src notEmptyOrNil ]) ifTrue:[
+                                (markupType == #script and:[ markup src notEmptyOrNil ]) ifTrue:[
                                     label := nm , ' ("',markup src,'")'
                                 ] ifFalse:[
-                                     label := nm
+                                    ( isHeader 
+                                          and:[text := self plainTextBetweenHTMLElement:markup andElementWithTag:('/',markupType).
+                                               text notEmpty] 
+                                    ) ifTrue:[
+                                        label := '"',text,'" (',nm,')'
+                                    ] ifFalse:[
+                                         label := nm
+                                    ]
                                 ]
                             ]
                         ].
                     ].
 
-
                     hideHolder value ~~ true ifTrue:[
                         tag := type 
                                     label:label 
@@ -2685,7 +2732,7 @@
     ^ targets
 
     "Created: / 20-04-2011 / 18:59:29 / cg"
-    "Modified: / 07-05-2011 / 17:04:53 / cg"
+    "Modified: / 12-09-2012 / 17:54:07 / cg"
 !
 
 javaScriptTagsInFile:aFilePath
@@ -3103,6 +3150,34 @@
     ^ targets
 !
 
+plainTextBetweenHTMLElement:startElement andElementWithTag:endTag
+    "applied to an <h1>-tag element, passing '/h1' as endTag,
+     this retrieves the plain text of the headline. Used by the tag list."
+
+    |el collector hasSpace txt|
+
+    collector := WriteStream on:(String new:100).
+    el := startElement next.
+    hasSpace := true.
+    [el tag ~= endTag] whileTrue:[
+        el isTextElement ifTrue:[
+            hasSpace ifFalse:[
+                collector space.
+                hasSpace := true.
+            ].
+            txt := el text withoutSeparators.
+            txt notEmpty ifTrue:[
+                collector nextPutAll:txt.
+                hasSpace := txt endsWith:' '.
+            ]
+        ].
+        el := el next
+    ].
+    ^ collector contents
+
+    "Created: / 12-09-2012 / 12:38:01 / cg"
+!
+
 prologTagsInFile:aFilePath
     "prolog tags:
      naive, q&d scan for lines matching:
@@ -3504,13 +3579,13 @@
 !TagList class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/Tools__TagList.st,v 1.16 2012/08/23 21:21:31 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/Tools__TagList.st,v 1.18 2012/09/12 15:59:53 cg Exp $'
 !
 
 version_CVS
-    ^ '§Header: /cvs/stx/stx/libtool/Tools__TagList.st,v 1.16 2012/08/23 21:21:31 cg Exp §'
+    ^ '§Header: /cvs/stx/stx/libtool/Tools__TagList.st,v 1.18 2012/09/12 15:59:53 cg Exp §'
 !
 
 version_SVN
-    ^ '$Id: Tools__TagList.st 8048 2012-09-07 17:28:09Z vranyj1 $'
+    ^ '$Id: Tools__TagList.st 8054 2012-09-13 09:15:20Z vranyj1 $'
 ! !