Re: Html Tag set classes

"Thierry Blanc [email protected] [sed-users]" <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
a two step solution, not as sophisticated as Scotts ...

sed -nr '
/class="time"/s|.*\.(20..)<.*|/blog\\/\1/s?a *href?a class="active" href?|p
/class="tags"/s|.*href="/blog/tags/([^/]*).*|/blog\\/tag\\/\1/s?a
*href?a class="active" href?|p
' data.html > sed.temp ; sed -rf sed.temp data.html


first script extracts the year and the tags, creates a sed script
'sed.temp'. sed.temp will change the data.html

question:
header has 'tags' with 's' (plural)

<span class="tags"><a href="/blog/tag*s*/society/">society</a>

bottom has only 'tag'

 <li><a href="/blog/tag/computer/">computer (3)</a></li>




On 27/07/15 23:34, Scott Walters [email protected] [sed-users]
wrote:
> Hello,
> One way is as follows.
>
> cat data.html |  sed  '
> /<span *class *= *"time"/{h; x; s/.*\(....\)<\/span>/\1/; x;}
> /<span *class *= *"tags"/{H; x; s/\n.*>\(.*\)<\/a>/,\1/;  x;}
> G;
> s/<a href="\/blog\/\([^\n]*\)\/">\1\(.*\)\n\1,/<a class="active" href="\/blog\/\1\/">\1\2\n\1,/;
> s/<a href="\/blog\/tag\/\([^\n]*\)\/">\(.*\)\n\(.*\),\1/<a class="active" href="\/blog\/tag\/\1\/">\2\n\3,\1/;
> P;
> d;'
> The output of the two lines would be as follows
> <li><a class="active" href="/blog/tag/society/">society (11)</a></li>
> <li><a class="active" href="/blog/2015/">2015 (7)</a></li>
>
> thanks
> Scott W. 
>
>
>      On Sunday, July 26, 2015 11:29 PM, "Scott Walters [email protected] [sed-users]" <[email protected]> wrote:
>    
>
>      Hello,
> One way is as follows.cat data.html |  sed  '/<span *class *= *"time"/{h; x; s/.*\(....\)<\/span>/\1/; x;}/<span *class *= *"tags"/{H; x; s/\n.*>\(.*\)<\/a>/,\1/;  x;}G;s/<a href="\/blog\/\([^\n]*\)\/">\1\(.*\)\n\1,/<a class="active" href="\/blog\/\1\/">\1\2\n\1,/;s/<a href="\/blog\/tag\/\([^\n]*\)\/">\(.*\)\n\(.*\),\1/<a class="active" href="\/blog\/tag\/\1\/">\2\n\3,\1/;P;d;'
> The output of the two lines would be as follows<li><a class="active" href="/blog/tag/society/">society (11)</a></li>
> <li><a class="active" href="/blog/2015/">2015 (7)</a></li>
>
> thanksScott W. 
>
> On Sunday, July 26, 2015 9:14 PM, "'[email protected]' [email protected] [sed-users]" <[email protected]> wrote:
>  
>
>   Hello,
>
> i convert my page to other static generator which understand not liquid
> template language and i can not convert in ruby template language. So 
> i ask me i can fix my problem maybe with sed. 
>
> Seeking a way to a particular term inside the head of a article (webpage)
> and then in footer want set active to class. It goes with tags and years. 
>
> For example in head, the tag is example together have five tags. 
>
> <span class="time">02.05.2015</span>
> <span class="tags"><a href="/blog/tags/society/">society</a>
>
> In Header should search year and tag. 
>
> Then in footer stand...
>
> <aside class="blog">
> <ul>
>  <li><a href="/blog/tag/computer/">computer (3)</a></li>
>  <li><a href="/blog/tag/society/">society (11)</a></li>
>  <li><a href="/blog/tag/state/">state (10)</a></li>
>  <li><a href="/blog/tag/media/">media (3)</a></li>
>  <li><a href="/blog/tag/network/">network (2)</a></li>
> </ul>
>  
> <ul>
>  <li><a href="/blog/2015/">2015 (7)</a></li>
>  <li><a href="/blog/2014/">2014 (14)</a></li>
>  <li><a href="/blog/2013/">2013 (4)</a></li>
>  <li><a href="/blog/2012/">2012 (4)</a></li>
> </ul>
> </aside>
>
> This is footer should then set class="active" when year and tag is matched. 
>
> Has someone an idea? This should work recursive, because middleman want me 
> not set this chance and my coding expierence is limited. 
>
> Thank You & Nice Day
> ----------------
> Silvio Siefke
>
> [Non-text portions of this message have been removed]
>
> #yiv8280509572 #yiv8280509572 -- #yiv8280509572ygrp-mkp {border:1px solid #d8d8d8;font-family:Arial;margin:10px 0;padding:0 10px;}#yiv8280509572 #yiv8280509572ygrp-mkp hr {border:1px solid #d8d8d8;}#yiv8280509572 #yiv8280509572ygrp-mkp #yiv8280509572hd {color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px 0;}#yiv8280509572 #yiv8280509572ygrp-mkp #yiv8280509572ads {margin-bottom:10px;}#yiv8280509572 #yiv8280509572ygrp-mkp .yiv8280509572ad {padding:0 0;}#yiv8280509572 #yiv8280509572ygrp-mkp .yiv8280509572ad p {margin:0;}#yiv8280509572 #yiv8280509572ygrp-mkp .yiv8280509572ad a {color:#0000ff;text-decoration:none;}#yiv8280509572 #yiv8280509572ygrp-sponsor #yiv8280509572ygrp-lc {font-family:Arial;}#yiv8280509572 #yiv8280509572ygrp-sponsor #yiv8280509572ygrp-lc #yiv82805095
 72hd {margin:10px 0px;font-weight:700;font-size:78%;line-height:122%;}#yiv8280509572 #yiv8280509572ygrp-sponsor #yiv8280509572ygrp-lc .yiv8280509572ad {margin-bottom:10px;padding:0 0;}#yiv8280509572 #yiv8280509572actions {font-family:Verdana;font-size:11px;padding:10px 0;}#yiv8280509572 #yiv8280509572activity {background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}#yiv8280509572 #yiv8280509572activity span {font-weight:700;}#yiv8280509572 #yiv8280509572activity span:first-child {text-transform:uppercase;}#yiv8280509572 #yiv8280509572activity span a {color:#5085b6;text-decoration:none;}#yiv8280509572 #yiv8280509572activity span span {color:#ff7900;}#yiv8280509572 #yiv8280509572activity span .yiv8280509572underline {text-decoration:underline;}#yiv8280509572 .y
 iv8280509572attach {clear:both;display:table;font-family:Arial;font-size:12px;padding:10px 0;width:400px;}#yiv8280509572 .yiv8280509572attach div a {text-decoration:none;}#yiv8280509572 .yiv8280509572attach img {border:none;padding-right:5px;}#yiv8280509572 .yiv8280509572attach label {display:block;margin-bottom:5px;}#yiv8280509572 .yiv8280509572attach label a {text-decoration:none;}#yiv8280509572 blockquote {margin:0 0 0 4px;}#yiv8280509572 .yiv8280509572bold {font-family:Arial;font-size:13px;font-weight:700;}#yiv8280509572 .yiv8280509572bold a {text-decoration:none;}#yiv8280509572 dd.yiv8280509572last p a {font-family:Verdana;font-weight:700;}#yiv8280509572 dd.yiv8280509572last p span {margin-right:10px;font-family:Verdana;font-weight:700;}#yiv8280509572 dd.yiv8280509572last p span.yiv
 8280509572yshortcuts {margin-right:0;}#yiv8280509572 div.yiv8280509572attach-table div div a {text-decoration:none;}#yiv8280509572 div.yiv8280509572attach-table {width:400px;}#yiv8280509572 div.yiv8280509572file-title a, #yiv8280509572 div.yiv8280509572file-title a:active, #yiv8280509572 div.yiv8280509572file-title a:hover, #yiv8280509572 div.yiv8280509572file-title a:visited {text-decoration:none;}#yiv8280509572 div.yiv8280509572photo-title a, #yiv8280509572 div.yiv8280509572photo-title a:active, #yiv8280509572 div.yiv8280509572photo-title a:hover, #yiv8280509572 div.yiv8280509572photo-title a:visited {text-decoration:none;}#yiv8280509572 div#yiv8280509572ygrp-mlmsg #yiv8280509572ygrp-msg p a span.yiv8280509572yshortcuts {font-family:Verdana;font-size:10px;font-weight:normal;}#yiv828050
 9572 .yiv8280509572green {color:#628c2a;}#yiv8280509572 .yiv8280509572MsoNormal {margin:0 0 0 0;}#yiv8280509572 o {font-size:0;}#yiv8280509572 #yiv8280509572photos div {float:left;width:72px;}#yiv8280509572 #yiv8280509572photos div div {border:1px solid #666666;height:62px;overflow:hidden;width:62px;}#yiv8280509572 #yiv8280509572photos div label {color:#666666;font-size:10px;overflow:hidden;text-align:center;white-space:nowrap;width:64px;}#yiv8280509572 #yiv8280509572reco-category {font-size:77%;}#yiv8280509572 #yiv8280509572reco-desc {font-size:77%;}#yiv8280509572 .yiv8280509572replbq {margin:4px;}#yiv8280509572 #yiv8280509572ygrp-actbar div a:first-child {margin-right:2px;padding-right:5px;}#yiv8280509572 #yiv8280509572ygrp-mlmsg {font-size:13px;font-family:Arial, helvetica, clean, san
 s-serif;}#yiv8280509572 #yiv8280509572ygrp-mlmsg table {font-size:inherit;font:100%;}#yiv8280509572 #yiv8280509572ygrp-mlmsg select, #yiv8280509572 input, #yiv8280509572 textarea {font:99% Arial, Helvetica, clean, sans-serif;}#yiv8280509572 #yiv8280509572ygrp-mlmsg pre, #yiv8280509572 code {font:115% monospace;}#yiv8280509572 #yiv8280509572ygrp-mlmsg * {line-height:1.22em;}#yiv8280509572 #yiv8280509572ygrp-mlmsg #yiv8280509572logo {padding-bottom:10px;}#yiv8280509572 #yiv8280509572ygrp-msg p a {font-family:Verdana;}#yiv8280509572 #yiv8280509572ygrp-msg p#yiv8280509572attach-count span {color:#1E66AE;font-weight:700;}#yiv8280509572 #yiv8280509572ygrp-reco #yiv8280509572reco-head {color:#ff7900;font-weight:700;}#yiv8280509572 #yiv8280509572ygrp-reco {margin-bottom:20px;padding:0px;}#yiv828
 0509572 #yiv8280509572ygrp-sponsor #yiv8280509572ov li a {font-size:130%;text-decoration:none;}#yiv8280509572 #yiv8280509572ygrp-sponsor #yiv8280509572ov li {font-size:77%;list-style-type:square;padding:6px 0;}#yiv8280509572 #yiv8280509572ygrp-sponsor #yiv8280509572ov ul {margin:0;padding:0 0 0 8px;}#yiv8280509572 #yiv8280509572ygrp-text {font-family:Georgia;}#yiv8280509572 #yiv8280509572ygrp-text p {margin:0 0 1em 0;}#yiv8280509572 #yiv8280509572ygrp-text tt {font-size:120%;}#yiv8280509572 #yiv8280509572ygrp-vital ul li:last-child {border-right:none !important;}#yiv8280509572 
>
> [Non-text portions of this message have been removed]
>
>   #yiv1919630769 #yiv1919630769 -- #yiv1919630769ygrp-mkp {border:1px solid #d8d8d8;font-family:Arial;margin:10px 0;padding:0 10px;}#yiv1919630769 #yiv1919630769ygrp-mkp hr {border:1px solid #d8d8d8;}#yiv1919630769 #yiv1919630769ygrp-mkp #yiv1919630769hd {color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px 0;}#yiv1919630769 #yiv1919630769ygrp-mkp #yiv1919630769ads {margin-bottom:10px;}#yiv1919630769 #yiv1919630769ygrp-mkp .yiv1919630769ad {padding:0 0;}#yiv1919630769 #yiv1919630769ygrp-mkp .yiv1919630769ad p {margin:0;}#yiv1919630769 #yiv1919630769ygrp-mkp .yiv1919630769ad a {color:#0000ff;text-decoration:none;}#yiv1919630769 #yiv1919630769ygrp-sponsor #yiv1919630769ygrp-lc {font-family:Arial;}#yiv1919630769 #yiv1919630769ygrp-sponsor #yiv1919630769ygrp-lc #yiv191963
 0769hd {margin:10px 0px;font-weight:700;font-size:78%;line-height:122%;}#yiv1919630769 #yiv1919630769ygrp-sponsor #yiv1919630769ygrp-lc .yiv1919630769ad {margin-bottom:10px;padding:0 0;}#yiv1919630769 #yiv1919630769actions {font-family:Verdana;font-size:11px;padding:10px 0;}#yiv1919630769 #yiv1919630769activity {background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}#yiv1919630769 #yiv1919630769activity span {font-weight:700;}#yiv1919630769 #yiv1919630769activity span:first-child {text-transform:uppercase;}#yiv1919630769 #yiv1919630769activity span a {color:#5085b6;text-decoration:none;}#yiv1919630769 #yiv1919630769activity span span {color:#ff7900;}#yiv1919630769 #yiv1919630769activity span .yiv1919630769underline {text-decoration:underline;}#yiv1919630769 
 .yiv1919630769attach {clear:both;display:table;font-family:Arial;font-size:12px;padding:10px 0;width:400px;}#yiv1919630769 .yiv1919630769attach div a {text-decoration:none;}#yiv1919630769 .yiv1919630769attach img {border:none;padding-right:5px;}#yiv1919630769 .yiv1919630769attach label {display:block;margin-bottom:5px;}#yiv1919630769 .yiv1919630769attach label a {text-decoration:none;}#yiv1919630769 blockquote {margin:0 0 0 4px;}#yiv1919630769 .yiv1919630769bold {font-family:Arial;font-size:13px;font-weight:700;}#yiv1919630769 .yiv1919630769bold a {text-decoration:none;}#yiv1919630769 dd.yiv1919630769last p a {font-family:Verdana;font-weight:700;}#yiv1919630769 dd.yiv1919630769last p span {margin-right:10px;font-family:Verdana;font-weight:700;}#yiv1919630769 dd.yiv1919630769last p span.y
 iv1919630769yshortcuts {margin-right:0;}#yiv1919630769 div.yiv1919630769attach-table div div a {text-decoration:none;}#yiv1919630769 div.yiv1919630769attach-table {width:400px;}#yiv1919630769 div.yiv1919630769file-title a, #yiv1919630769 div.yiv1919630769file-title a:active, #yiv1919630769 div.yiv1919630769file-title a:hover, #yiv1919630769 div.yiv1919630769file-title a:visited {text-decoration:none;}#yiv1919630769 div.yiv1919630769photo-title a, #yiv1919630769 div.yiv1919630769photo-title a:active, #yiv1919630769 div.yiv1919630769photo-title a:hover, #yiv1919630769 div.yiv1919630769photo-title a:visited {text-decoration:none;}#yiv1919630769 div#yiv1919630769ygrp-mlmsg #yiv1919630769ygrp-msg p a span.yiv1919630769yshortcuts {font-family:Verdana;font-size:10px;font-weight:normal;}#yiv1919
 630769 .yiv1919630769green {color:#628c2a;}#yiv1919630769 .yiv1919630769MsoNormal {margin:0 0 0 0;}#yiv1919630769 o {font-size:0;}#yiv1919630769 #yiv1919630769photos div {float:left;width:72px;}#yiv1919630769 #yiv1919630769photos div div {border:1px solid #666666;height:62px;overflow:hidden;width:62px;}#yiv1919630769 #yiv1919630769photos div label {color:#666666;font-size:10px;overflow:hidden;text-align:center;white-space:nowrap;width:64px;}#yiv1919630769 #yiv1919630769reco-category {font-size:77%;}#yiv1919630769 #yiv1919630769reco-desc {font-size:77%;}#yiv1919630769 .yiv1919630769replbq {margin:4px;}#yiv1919630769 #yiv1919630769ygrp-actbar div a:first-child {margin-right:2px;padding-right:5px;}#yiv1919630769 #yiv1919630769ygrp-mlmsg {font-size:13px;font-family:Arial, helvetica, clean, s
 ans-serif;}#yiv1919630769 #yiv1919630769ygrp-mlmsg table {font-size:inherit;font:100%;}#yiv1919630769 #yiv1919630769ygrp-mlmsg select, #yiv1919630769 input, #yiv1919630769 textarea {font:99% Arial, Helvetica, clean, sans-serif;}#yiv1919630769 #yiv1919630769ygrp-mlmsg pre, #yiv1919630769 code {font:115% monospace;}#yiv1919630769 #yiv1919630769ygrp-mlmsg * {line-height:1.22em;}#yiv1919630769 #yiv1919630769ygrp-mlmsg #yiv1919630769logo {padding-bottom:10px;}#yiv1919630769 #yiv1919630769ygrp-msg p a {font-family:Verdana;}#yiv1919630769 #yiv1919630769ygrp-msg p#yiv1919630769attach-count span {color:#1E66AE;font-weight:700;}#yiv1919630769 #yiv1919630769ygrp-reco #yiv1919630769reco-head {color:#ff7900;font-weight:700;}#yiv1919630769 #yiv1919630769ygrp-reco {margin-bottom:20px;padding:0px;}#yiv1
 919630769 #yiv1919630769ygrp-sponsor #yiv1919630769ov li a {font-size:130%;text-decoration:none;}#yiv1919630769 #yiv1919630769ygrp-sponsor #yiv1919630769ov li {font-size:77%;list-style-type:square;padding:6px 0;}#yiv1919630769 #yiv1919630769ygrp-sponsor #yiv1919630769ov ul {margin:0;padding:0 0 0 8px;}#yiv1919630769 #yiv1919630769ygrp-text {font-family:Georgia;}#yiv1919630769 #yiv1919630769ygrp-text p {margin:0 0 1em 0;}#yiv1919630769 #yiv1919630769ygrp-text tt {font-size:120%;}#yiv1919630769 #yiv1919630769ygrp-vital ul li:last-child {border-right:none !important;}#yiv1919630769 
>
>   
>
> [Non-text portions of this message have been removed]
>
>
>
> ------------------------------------
> Posted by: Scott Walters <[email protected]>
> ------------------------------------
>



[Non-text portions of this message have been removed]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.