Snippets syntax: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
Line 26: | Line 26: | ||
# <nowiki><branch title="Facebook"></nowiki> | # <nowiki><branch title="Facebook"></nowiki> | ||
# <nowiki><leaf type="insert" title="bold"><before></nowiki><span style="color:red">&lt;</span><nowiki>b</nowiki><span style="color:red">&gt;</span><nowiki></before><after></nowiki><span style="color:red">&lt;</span><nowiki>/b</nowiki><span style="color:red">&gt;</span><nowiki></after></leaf></nowiki> | # <nowiki><leaf type="insert" title="bold"><before></nowiki><span style="color:red">&lt;</span><nowiki>b</nowiki><span style="color:red">&gt;</span><nowiki></before><after></nowiki><span style="color:red">&lt;</span><nowiki>/b</nowiki><span style="color:red">&gt;</span><nowiki></after></leaf></nowiki> | ||
# <nowiki><leaf type="insert" title="italic"><before></nowiki><span style="color:red">&lt;</span><nowiki>i</nowiki><span style="color:red">&gt;</span><nowiki></before><after></nowiki><span style="color:red">&lt;</span><nowiki>/i</nowiki><span style="color:red">&gt;</span><nowiki></after></leaf></nowiki> | # <nowiki><leaf type="insert" title="italic"</nowiki><span style="color:blue"> tooltip="insert an italic tag"</span><nowiki>><before></nowiki><span style="color:red">&lt;</span><nowiki>i</nowiki><span style="color:red">&gt;</span><nowiki></before><after></nowiki><span style="color:red">&lt;</span><nowiki>/i</nowiki><span style="color:red">&gt;</span><nowiki></after></leaf></nowiki> | ||
# <nowiki><leaf type="insert" title="Hyperlink"><before></nowiki><span style="color:red">&lt;</span | # <nowiki><leaf type="insert" title="Hyperlink"><before></nowiki><span style="color:red">&lt;</span>a href="<span style="color:blue">%0</span>"<span style="color:red">&gt;</span><nowiki></before><after></nowiki><span style="color:red">&lt;</span><nowiki>/a</nowiki><span style="color:red">&gt;</span><nowiki></after></nowiki><span style="color:blue"><nowiki><param name="url"/></nowiki></span><nowiki></leaf></nowiki> | ||
# <nowiki><leaf type="insert" title="em-dash"><before></nowiki><span style="color:red">&</span><span style="color:red">amp;</span><nowiki>mdash;</before></nowiki><span style="color:blue"><nowiki><after></after></nowiki></span><nowiki></leaf></nowiki> | # <nowiki><leaf type="insert" title="em-dash"><before></nowiki><span style="color:red">&</span><span style="color:red">amp;</span><nowiki>mdash;</before></nowiki><span style="color:blue"><nowiki><after></after></nowiki></span><nowiki></leaf></nowiki> | ||
# <nowiki></branch></nowiki> | # <nowiki></branch></nowiki> | ||
# <nowiki></snippets></nowiki> | # <nowiki></snippets></nowiki> | ||
</ol> | |||
;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). | |||
=== Search and replace snippets === | === Search and replace snippets === | ||
{{Man2bottom | {{Man2bottom |
Revision as of 19:27, 20 March 2010
The snippets are stored in ~/.bluefish/snippets. It is an XML file, like import and export snippets files.
- 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
- <?xml version="1.0"?>
- <snippets>
- <branch title="Facebook">
- <leaf type="insert" title="bold"><before><b></before><after></b></after></leaf>
- <leaf type="insert" title="italic" tooltip="insert an italic tag"><before><i></before><after></i></after></leaf>
- <leaf type="insert" title="Hyperlink"><before><a href="%0"></before><after></a></after><param name="url"/></leaf>
- <leaf type="insert" title="em-dash"><before>&mdash;</before><after></after></leaf>
- </branch>
- </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).