Advertisement
Guest User

HTML Comment Cutter

a guest
Jan 14th, 2020
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.14 KB | None | 0 0
  1. #/bin/bash
  2. sed_prg=\
  3. $(cat <<EOF
  4. $,/.*/ {    
  5.     H #Append new data to hold space
  6.     x #Exchange hold space with pattern space
  7.     s/<!--.*-->//g #Delete comment
  8.     p #Print pattern space
  9.   }    
  10. #If we don't yet have a terminating comment just append to the hold space and start the next cycle.
  11. /.*-->.*/! {
  12.   H #Append pattern space to hold space
  13.   d #Delete pattern space and start next cycle
  14.   }
  15. #If we have a closing comment append data to hold space and copy the hold space to the pattern space to see if we can match both an opening and closing comment in pattern space.
  16. /.*-->.*/ {
  17.     H #Append new data to hold space
  18.     x #Exchange hold space with pattern space
  19.     h #Copy pattern space to hold space
  20.   }
  21. #If this block matches the previous block has already been executed and this block will be executed next.
  22. /.*<!--.*-->.*/ {
  23.     s/<!--.*-->//g #Delete comment
  24.     p #Print pattern space
  25.     s/.*//g #delete pattern space
  26.     x #exchange pattern space with hold space
  27.     d #delete pattern space and start next cycle.
  28.   }
  29.  
  30. EOF
  31. )
  32. #echo "$sed_prg"
  33.  
  34. sed_input=\
  35. $(cat <<EOF
  36. <JWM>
  37.    <Tray  autohide="false" insert="right" x="0" y="-1" border="1" height="28" >
  38.       <!-- Additional TrayButton attribute: label -->
  39.       <TrayButton label="Menu" icon="logo-mini.png" border="true">root:3</TrayButton>
  40. border="true">exec:urxvt</TrayButton>
  41.       <Pager/>
  42.       <!-- Additional TaskList attribute: maxwidth -->
  43.       <TaskList maxwidth="200"/>
  44.       <Dock/>
  45.       <!-- Additional Swallow attribute: height -->
  46.    <!--   <Swallow name="blinky">
  47.          blinkydelayed -bg "#DCDAD5"
  48.       </Swallow> -->
  49.    <!--   <Swallow name="xtmix-launcher">
  50.          xtmix -launch
  51.       </Swallow> -->
  52.    <!--   <Swallow name="asapm">
  53.          asapmshell -u 4
  54.       </Swallow> -->
  55.    <!--   <Swallow name="freememapplet" width="34">
  56.          freememappletshell
  57.       </Swallow> -->
  58.       <Swallow name="xload" width="32">
  59.          xload -nolabel -bg "#888888" -fg red -hl white
  60.       </Swallow>
  61.       <Clock format="%H:%M">minixcal</Clock>
  62.    </Tray>
  63. </JWM>
  64. EOF
  65. )
  66. #echo "$sed_input"
  67.  
  68. echo "$sed_input" | sed -n "${sed_prg}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement