CSS to snippets snippets: Difference between revisions

From Bluefish Wiki
Jump to navigation Jump to search
Fal7i (talk | contribs)
mNo edit summary
Fal7i (talk | contribs)
m rename css2snippets css_to_snippets
 
(3 intermediate revisions by the same user not shown)
Line 4: Line 4:
<?xml version="1.0"?>
<?xml version="1.0"?>


<!-- css2snippets create a snippet branch from any CSS stylesheet -->  
<!-- css_to_snippets create a snippet branch from any CSS stylesheet -->  
<!-- css2snippets.xml $Revision: 22/3/2010  -->
<!-- css_to_snippets.xml $Revision: 22/3/2010  -->


<!--
<!--
Line 28: Line 28:


<snippets>
<snippets>
<branch title="css2snippets">
<branch title="css_to_snippets">
<leaf type="snr" title="rm brackets" tooltip="Remove all poperties declarations." region="b" matchtype="perl" casesens="0" escapechars="1">
<leaf type="snr" title="rm brackets" tooltip="Remove all poperties declarations." region="b" matchtype="perl" casesens="0" escapechars="1">
<searchpat>{[^}]*}</searchpat>
<searchpat>{[^}]*}</searchpat>

Latest revision as of 10:23, 10 February 2011



<?xml version="1.0"?>

<!-- css_to_snippets create a snippet branch from any CSS stylesheet --> 
<!-- css_to_snippets.xml $Revision: 22/3/2010   -->

<!--
              DO NOT COPY THIS FILE FROM THE WIKI MAIN PAGE!
     BUT FROM THE EDIT TAB (OR THE VIEW SOURCE IF YOU ARE NOT LOGGIN IN)
               ONLY THE PART WITHIN: <pre> </pre>
-->


<!-- USAGE:
	Copy and import this file.
	Open a xxx.css stylesheet.
	1) apply in order: `rm brackets`, `rm comments`, `split ,`,
	`split .`, `rm :` and `split spaces`.
	2) run Tools>Files>sort / uniq
	3) remove all unwanted lines
	4) apply `div` and `span`.
	5) go to the fist line and apply `Header`
	6) go to the end of the file and apply `Footer`
	7) save the file as `xxx.xml` and import it in snippets left panel menu.
 -->

<snippets>
<branch title="css_to_snippets">
<leaf type="snr" title="rm brackets" tooltip="Remove all poperties declarations." region="b" matchtype="perl" casesens="0" escapechars="1">
<searchpat>{[^}]*}</searchpat>
<replacepat>\n</replacepat>
</leaf>
<leaf type="snr" title="rm comments" tooltip="Remove all CSS comments." region="b" matchtype="perl" casesens="0" escapechars="0">
<searchpat>/\*[^*]*\*/</searchpat>
<replacepat> </replacepat>
</leaf>
<leaf type="snr" title="split ," tooltip="split ," region="b" matchtype="posix" casesens="0" escapechars="1">
<searchpat>,[ ]*</searchpat>
<replacepat>\n</replacepat>
</leaf>
<leaf type="snr" title="split ." tooltip="split ." region="b" matchtype="normal" casesens="0" escapechars="1">
<searchpat>.</searchpat>
<replacepat>\n.</replacepat>
</leaf>
<leaf type="snr" title="rm :" tooltip="Remove Anchor Pseudo-classes" region="b" matchtype="perl" casesens="0" escapechars="0">
<searchpat>:\w+</searchpat>
<replacepat> </replacepat>
</leaf>
<leaf type="snr" title="split spaces" tooltip="split spaces" region="b" matchtype="normal" casesens="0" escapechars="1">
<searchpat> </searchpat>
<replacepat>\n</replacepat>
</leaf>
<leaf type="snr" title="INFO: sort/uniq now!" tooltip="This snippet make nothing!
It is here only to remember to run now:
Tools>Filters>Sort/Uniq and after that
remove uneeded lines." region="b" matchtype="normal" casesens="0" escapechars="0">
<searchpat> </searchpat>
<replacepat> </replacepat>
</leaf>
<leaf type="snr" title="div" tooltip="Create div tags with id attribute
 from all #selectors" region="b" matchtype="perl" casesens="0" escapechars="0">
<searchpat>#([-_a-zA-Z0-9]*)</searchpat>
<replacepat><leaf type="insert" title="\1"><before>&lt;div id="\1"&gt;
</before><after>
&lt;/div&gt;</after></leaf></replacepat>
</leaf>
<leaf type="snr" title="span" tooltip="Create span tags with class attribute from 
all class selectors." region="b" matchtype="perl" casesens="0" escapechars="0">
<searchpat>\.([-_a-zA-Z0-9]*)</searchpat>
<replacepat><leaf type="insert" title="\1"><before>&lt;span class="\1"&gt;</before><after>&lt;/class&gt;</after></leaf></replacepat>
</leaf>
<leaf type="insert" title="Header" tooltip="Header to add at the top of the file">
<before><?xml version="1.0"?>
<snippets>
<branch title="%0"></before>
<after/>
<param name="branch title"/>
</leaf>
<leaf type="insert" title="Footer" tooltip="Footer to add at the end of the file.">
<before></branch>
</snippets></before>
<after/>
</leaf>
</branch>
</snippets>