Changeset 1218

Show
Ignore:
Timestamp:
08/11/2008 10:03:54 AM (2 years ago)
Author:
DotMG
Message:

refs #503

Linkifying header to itself (anchor), to make easy copying anchor hrefs.

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/css/wikka.css

    r1211 r1218  
    9494        text-decoration: none; 
    9595        color: #333;     
     96} 
     97 
     98.page h1:hover:after, .page h2:hover:after, .page h3:hover:after, .page h4:hover:after, .page h5:hover:after, .page h6:hover:after { 
     99        color: #aaa; content: "\0020\0020\00b6"; 
     100} 
     101 
     102a.heading { 
     103        color: #000; 
     104} 
     105 
     106a.heading:hover { 
     107        color: #000; 
     108        text-decoration: none; 
    96109} 
    97110 
  • trunk/formatters/wakka.php

    r1162 r1218  
    121121                                        // now create id based on resulting heading text 
    122122                                        $h_id = $wakka->makeId('hn', $headingtext); 
     123 
     124                                        #503 - The text of a heading is now becoming a link to this heading, allowing an easy way to copy link to clipboard. 
     125                                        // For this, we take the textNode child of a heading, and if it is not enclosed in <a...></a>, we enclose it in  
     126                                        // $opening_anchor and $closing_anchor. 
     127                                        $opening_anchor = '<a class="heading" href="#'.$h_id.'">'; 
     128                                        $closing_anchor = '</a>'; 
     129                                        /** 
     130                                         * Match "<a " when it isn't preceded by "</a>" 
     131                                         */ 
     132                                        define('PATTERN_OPEN_A_ALONE', '(?<!</a>|^)<a '); 
     133                                        /** 
     134                                         * Match the end of a string when the string doesn't end with </a> 
     135                                         */ 
     136                                        define('PATTERN_END_OF_STRING_ALONE', '(?<!</a>)$'); 
     137                                        /** 
     138                                         * Match "</a>" when it is not followed by an opening link markup (<a ) 
     139                                         */ 
     140                                        define('PATTERN_CLOSE_A_ALONE', '</a>(?!<a |$)'); 
     141                                        /** 
     142                                         * Match the start of a string when the string doesn't start with "<a " 
     143                                         */ 
     144                                        define('PATTERN_START_OF_STRING_ALONE', '^(?!<a )'); 
     145                                        $h_heading = preg_replace('@('.PATTERN_OPEN_A_ALONE. '|'.PATTERN_END_OF_STRING_ALONE.  ')@', $closing_anchor.'\\0', $h_heading); 
     146                                        $h_heading = preg_replace('@('.PATTERN_CLOSE_A_ALONE.'|'.PATTERN_START_OF_STRING_ALONE.')@', '\\0'.$opening_anchor, $h_heading); 
    123147 
    124148                                        // rebuild element, adding id