Difference between revisions of "Snippets syntax"

From Bluefish Wiki
Jump to: navigation, search
m (Insert snippets)
m (My stylesheet to snippets)
Line 62: Line 62:
== My stylesheet to snippets ==
== My stylesheet to snippets ==
;todo: see in [[:Category:Snippets repository]] Bluefish css2snippets snippets

Revision as of 14:34, 22 March 2010

this page is updated for Manual 2. It needs to be verified! once you have verified this page (and corrected if necessary) please modify the status to v (verified), i.e. st=v (see Guidelines for Writing this Manual)

Man2 icon 48.png
Chapter VII. More than a Text Editor
Snippets syntax

The snippets are stored in ~/.bluefish/snippets. It is an XML file, like import and export snippets files.

Bluefish has an excellent editor snippets. So it is useless to read this page unless you intend to create a large number of snippets from some documentation, eg: SVG, DOM, etc.

  • The import file must have a valid XML syntax.
  • The document must include the header: <?xml version="1.0"?>.
  • The document must be included in the container: <snippets> <snippets>
  • Any snippet must be contained in a branch: <branch title="example"> </branch>
  • The branches may contain other branches.
  • Each snippet is described in a container: <leaf> </leaf>

Syntax examples

There are two types of snippets: insert and snr, aka Search N Replace.

Insert snippets

    1. <?xml version="1.0"?>
    2. <snippets>
    3. <branch title="Facebook">
    4. <leaf type="insert" title="bold"><before>&lt;b&gt;</before><after>&lt;/b&gt;</after></leaf>
    5. <leaf type="insert" title="italic" tooltip="insert an italic tag"><before>&lt;i&gt;</before><after>&lt;/i&gt;</after></leaf>
    6. <leaf type="insert" title="Hyperlink"><before>&lt;a href="%0"&gt;</before><after>&lt;/a&gt;</after><param name="url"/></leaf>
    7. <leaf type="insert" title="em-dash"><before>&amp;mdash;</before><after></after></leaf>
    8. </branch>
    9. </snippets>
First and important, 
if you want to insert any XML reserved characters ie: < > & you have to escape them (red highlighted in example).
  • A leaf tag must have type and title attributes,
  • it also may have a tooltip attribute (line 5 of example).
  • Before tag is used for text to insert before, and after tag for text inserted after.
  • You have to add one or more param tags (with name attibute) if you want tu use parameters (line 6 of example).
<param num="1" name="image"/>
Is file path

Search and replace snippets

SnR snippets are a little more complex:

<leaf type="snr" title="replace 1" tooltip="introduce events" region="b" matchtype="normal" casesens="0" escapechars="0">
 <replacepat>jpg" alt="" onmouseout="out(this);" onmouseover="popup(this,'th/</replacepat>

searchpat and replacepat tags,
are replacing before and after tags.
leaf tag have new attibutes,
values: b (Entire document), c (forword from cursor position), s (Selection), or a (All open files).
values: normal, word, posix or perl.
values: 1 (set) or 0 (unset).
values: 1 (set) or 0 (unset).

My stylesheet to snippets

see in Category:Snippets repository Bluefish css2snippets snippets

7.Snippets plugin
Home | ToC
 Chapter VIII. Customising Bluefish