External Programs and Filters: Difference between revisions
(6 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
|lang=en | |lang=en | ||
|rev=2.0.0 | |rev=2.0.0 | ||
|st= | |st=u | ||
|Title=8. External programs, filters | |Title=8. External programs, filters | ||
|prev=Snippets plugin | |prev=Snippets plugin | ||
Line 9: | Line 9: | ||
}} | }} | ||
note for | {{toc}} | ||
External programmes can be called from within Bluefish. The currently opened file can be given as a parameter. External programmes are divided into three parts: | |||
# '''external commands: '''With an external command you can just open a file in an other programme, e.g. a browser. If that programme changed the file, Bluefish will warn you some moments later. | |||
# '''external filters:''' In contrast to external commands, external filters give a return value. | |||
# '''output box:''' Programmes in that category opens also the output box at the bottom of Bluefish. | |||
By default, for all three are already defined commands. | |||
{{note|text='''Note''': The external programmes are not necessarily installed on your computer, so you may have to install them at first. Bluefish will give you a warning if that programme is not installed.}} | |||
= External commands = | |||
External commands are mostly browsers. The external commands can be reached through ''Tools → Commands''. With the ''Preview in Browser ''button on the toolbar you can open the default browser, which is also an external programme. | |||
== Customising external commands == | |||
For customising external commands you have to open the ''Preferences'' dialog either through ''Edit → Preferences'' or the ''Preferences'' button on the toolbar. Select ''External commands'' in the left panel. | |||
There are four columns for editing external commands: | |||
* '''Enabled:''' If this is checked, you are able to reach that command through ''Tools → Commands''. | |||
* '''Label:''' The name of the command in menu. | |||
* '''Command:''' Here is the command. | |||
* '''Default browser:''' The checked programme can accessed through the ''Preview in Browser'' button at the toolbar. | |||
These are the options for external commands: | |||
{| style="border-spacing:0;width: 75%" | |||
| colspan="2" style="border:0.05pt solid #000000;padding:0.097cm;"| '''Input options''' | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| | | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| start with a | to send the input to the standard input | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| %f | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| local file name (available for local files) | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| %i | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| temporary file name for input, equals %f if the document is not modified and local | |||
|- | |||
| colspan="2" style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| '''Other options''' | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| %a | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| additional arguments that will be asked when this filter is activated | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| %c | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| local directory of file (available for local files) | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| %n | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| file name without path (available for all titled files) | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| %u | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| URL (available for all titled files) | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| %p | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| preview URL if basedir and preview dir are set in project settings, else identical to %u | |||
|} | |||
== Predefined external commands == | |||
{| style="border-spacing:0;width: 75%" | |||
| style="border-top:0.05pt solid #000000;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| '''Name''' | |||
| style="border-top:0.05pt solid #000000;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| '''Command''' | |||
| style="border:0.05pt solid #000000;padding:0.097cm;"| '''Description''' | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| chmod a+x | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| chmod a+x %f | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| File f will be executable for all users on Unix-like system. | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Firefox | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| firefox 'firefox '%p'& | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Chromium | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| chromium-browser '%p'& | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| The open source base for the Chrome browser. | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Opera | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| opera -remote 'openURL(%p)' <nowiki>||</nowiki> opera '%p'& | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Konqueror | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| konqueror '%p'& | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Browser for the KDE desktop environment | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Links2 | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| links2 -g '%p'& | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| A text based browser | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Epiphany | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| epiphany-browser -n '%p'& | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Browser created by the GNOME project | |||
|} | |||
= External filters = | |||
The external commands can be reached through ''Tools → Filters''. | |||
== Customising external filters == | |||
For customising external commands you have to open the ''Preferences'' dialog either through ''Edit → Preferences'' or the ''Preferences'' button on the toolbar. Select ''External filters'' in the left panel. | |||
There are three columns for editing external filters: | |||
* '''Enabled:''' If this is checked, you are able to reach that filter through ''Tools → Filters''. | |||
* '''Label:''' The name of the filter in menu. | |||
* '''Command''': Here is the filter itself. | |||
These are the options for external filters: | |||
{| style="border-spacing:0;width: 75%" | |||
| colspan="2" style="border:0.05pt solid #000000;padding:0.097cm;"| '''Input options''' | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| | | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| start with a | to send the input to the standard input | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| %f | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| local file name (requires local file, cannot operate on selection) | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| %i | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| temporary file name for input | |||
|- | |||
| colspan="2" style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| '''Output options''' | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| | | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| end with a | to read the output from the standard output | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| %o | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| temporary file name | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| %t | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| temporary file name for both input and output (for in-place-editing filters, cannot operate on selection) | |||
|- | |||
| colspan="2" style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| '''Other options''' | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| %a | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| additional arguments that will be asked when this filter is activated | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| %c | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| local directory of file (requires local file) | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| %n | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| file name without path (available for all titled files) | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| %u | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| URL (available for all titled files) | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| %p | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| preview URL if basedir and preview dir are set in project settings, else identical to %u | |||
|} | |||
=== Using a Python programme as an external filter === | |||
For this example we'll use a simplified programme to create a filename out of a short chunk of text like a title or a headline. Due to we'll have an input as well an output as pipes, we need the following basic structure: | |||
<pre>import sys | |||
a = sys.stdin.read() | |||
sys.stdout.write(a)</pre> | |||
Within that basic structure we include the replacements for our task: | |||
<pre>import sys | |||
filename = sys.stdin.read() | |||
filename = filename.replace(" ", "-").lower() | |||
filename = filename.replace("/", "-") | |||
#Further replacements for e. g. 'ä' | |||
sys.stdout.write(filename)</pre> | |||
Save this script at a suitable place and open ''Preferences'' and select ''External filters'' in the left panel to add the script to the filters list. Give the entry a suitable name like toFileName and as command | |||
<pre>|python3 /path/to/scripts/toFileName.py|</pre> | |||
== Predefined external filters == | |||
{| style="border-spacing:0;width: 75%" | |||
| style="border-top:0.05pt solid #000000;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| '''Name''' | |||
| style="border-top:0.05pt solid #000000;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| '''Command''' | |||
| style="border:0.05pt solid #000000;padding:0.097cm;"| '''Description''' | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Sort | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| |sort| | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| ''sort'' is a sorting program for Unix-like systems. | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Sort/Uniq | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| |sort|uniq| | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| ''uniq'' removes duplicates after the input is sorted by ''sort''. It is also a program for Unix-like systems included in mysys. | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Reverse lines | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| |tac| | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Dos2unix | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| |dos2unix| | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Converts DOS line breaks to Unix line breaks. It is also a program for Unix-like systems included in mysys. | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Tidy HTML | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| |tidy -utf8| | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Improves the HTML with tidy program. | |||
== | |- | ||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Tidy convert in XHTML | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| |tidy -utf8 -i -w 80 -c -q -asxhtml| | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Converts HTML to XHTML with tidy. | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Tidy HTML (perltidy) | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| |perltidy -b| | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| (strawberry) | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Strip empty lines | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| |egrep -v '^[ ]*$'| | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Deleting empty lines using regular expressions with egrep. | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Render HTML in Text | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| lynx -force_html -dump %i | | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| PHP Beautifier | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| |php_beautifier -t| | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Improves PHP code with indentation of one tab. | |||
# | |- | ||
# | | style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Javascript Minify with jsmin | ||
# | | style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| |/usr/share/bluefish/jsmin.py| | ||
# | | style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Minifies Javascript code with a Python script, which is provided by bluefish. | ||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| CSS Minify with cssmin | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| |/usr/share/bluefish/cssmin.py| | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Minifies CSS code with a Python script, which is provided by bluefish. | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| CSS tidy | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| |csstidy --preserve_css=true -| | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Optimises CSS code. | |||
|} | |||
= Output box = | |||
The external commands can be reached through ''Tools → Outputbox''. | |||
== Customising output box == | |||
For customising external commands you have to open the ''Preferences'' dialog either through ''Edit → Preferences'' or the ''Preferences'' button on the toolbar. Select ''Output parsers'' in the left panel. | |||
There are seven columns for editing external filters: | |||
''' | * '''Enabled:''' If this is checked, you are able to reach that command through ''Tools → Filters''. | ||
* '''Name:''' The name of the command in menu. | |||
* '''Pattern''': Here is a regexp pattern send with the command. | |||
* '''File #''' | |||
* '''Line #''' | |||
* '''Output #''' | |||
* '''Command: '''Here is the command. | |||
These are the options for the output box: | |||
{| style="border-spacing:0;width: 75%" | |||
| colspan="2" style="border:0.05pt solid #000000;padding:0.097cm;"| '''Input options''' | |||
# | |- | ||
# | | style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| | | ||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| start with a | to send the input to the standard input | |||
# | |||
# | |||
# | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| %f | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| local file name (requires local file, cannot operate on selection) | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| %i | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| temporary file name for input | |||
== | |- | ||
| colspan="2" style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| '''Output options''' | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| | | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| end with a | to read the output from the standard output | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| %o | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| temporary file name | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| %t | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| temporary file name for both input and output (for in-place-editing "filters, cannot operate on selection) | |||
|- | |||
| colspan="2" style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| '''Other options''' | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| %a | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| additional arguments that will be asked when this filter is activated | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| %c | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| local directory of file (requires local file) | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| %n | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| file name without path (available for all titled files) | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| %u | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| URL (available for all titled files) | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| %p | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| preview URL if basedir and preview dir are set in project settings, else identical to %u | |||
|} | |||
== Predefined output parsers == | |||
{ | {| style="border-spacing:0;width: 75%" | ||
| style="border-top:0.05pt solid #000000;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| '''Name''' | |||
| style="border-top:0.05pt solid #000000;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| '''Command''' | |||
| style="border:0.05pt solid #000000;padding:0.097cm;"| '''Description''' | |||
# | |- | ||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| make | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| |cd %c && make| | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Runs the make build tool. | |||
== | |- | ||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| weblint HTML-Check | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| |weblint '%f'| | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| tidy HTML-Check | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| |tidy -qe '%i'| | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| javac | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| |javac '%f'| | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Compiles Java code. A JDK has to be installed. | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| xmllint XML-Check | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| |xmllint --noout --valid '%f'| | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| PHP | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| |php '%f'| | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Runs a PHP script. | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| PHP syntax check | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| |php -l -q -f '%f'| | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Cecks syntax and runs the PHP script. | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Perl syntax check | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| |perl -c '%f'| | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Checks only the syntax of the Perl script. | |||
|- | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| PHP Codesniffer | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| |phpcs --report=emacs '%f'| | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| | |||
'' | |- | ||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| pylint | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| |pylint '%f'| | |||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| | |||
|} | |||
Latest revision as of 08:37, 9 April 2021
External programmes can be called from within Bluefish. The currently opened file can be given as a parameter. External programmes are divided into three parts:
- external commands: With an external command you can just open a file in an other programme, e.g. a browser. If that programme changed the file, Bluefish will warn you some moments later.
- external filters: In contrast to external commands, external filters give a return value.
- output box: Programmes in that category opens also the output box at the bottom of Bluefish.
By default, for all three are already defined commands.
|
External commands[edit]
External commands are mostly browsers. The external commands can be reached through Tools → Commands. With the Preview in Browser button on the toolbar you can open the default browser, which is also an external programme.
Customising external commands[edit]
For customising external commands you have to open the Preferences dialog either through Edit → Preferences or the Preferences button on the toolbar. Select External commands in the left panel.
There are four columns for editing external commands:
- Enabled: If this is checked, you are able to reach that command through Tools → Commands.
- Label: The name of the command in menu.
- Command: Here is the command.
- Default browser: The checked programme can accessed through the Preview in Browser button at the toolbar.
These are the options for external commands:
Input options | |
| | start with a | to send the input to the standard input |
%f | local file name (available for local files) |
%i | temporary file name for input, equals %f if the document is not modified and local |
Other options | |
%a | additional arguments that will be asked when this filter is activated |
%c | local directory of file (available for local files) |
%n | file name without path (available for all titled files) |
%u | URL (available for all titled files) |
%p | preview URL if basedir and preview dir are set in project settings, else identical to %u |
Predefined external commands[edit]
Name | Command | Description |
chmod a+x | chmod a+x %f | File f will be executable for all users on Unix-like system. |
Firefox | firefox 'firefox '%p'& | |
Chromium | chromium-browser '%p'& | The open source base for the Chrome browser. |
Opera | opera -remote 'openURL(%p)' || opera '%p'& | |
Konqueror | konqueror '%p'& | Browser for the KDE desktop environment |
Links2 | links2 -g '%p'& | A text based browser |
Epiphany | epiphany-browser -n '%p'& | Browser created by the GNOME project |
External filters[edit]
The external commands can be reached through Tools → Filters.
Customising external filters[edit]
For customising external commands you have to open the Preferences dialog either through Edit → Preferences or the Preferences button on the toolbar. Select External filters in the left panel.
There are three columns for editing external filters:
- Enabled: If this is checked, you are able to reach that filter through Tools → Filters.
- Label: The name of the filter in menu.
- Command: Here is the filter itself.
These are the options for external filters:
Input options | |
| | start with a | to send the input to the standard input |
%f | local file name (requires local file, cannot operate on selection) |
%i | temporary file name for input |
Output options | |
| | end with a | to read the output from the standard output |
%o | temporary file name |
%t | temporary file name for both input and output (for in-place-editing filters, cannot operate on selection) |
Other options | |
%a | additional arguments that will be asked when this filter is activated |
%c | local directory of file (requires local file) |
%n | file name without path (available for all titled files) |
%u | URL (available for all titled files) |
%p | preview URL if basedir and preview dir are set in project settings, else identical to %u |
Using a Python programme as an external filter[edit]
For this example we'll use a simplified programme to create a filename out of a short chunk of text like a title or a headline. Due to we'll have an input as well an output as pipes, we need the following basic structure:
import sys a = sys.stdin.read() sys.stdout.write(a)
Within that basic structure we include the replacements for our task:
import sys filename = sys.stdin.read() filename = filename.replace(" ", "-").lower() filename = filename.replace("/", "-") #Further replacements for e. g. 'ä' sys.stdout.write(filename)
Save this script at a suitable place and open Preferences and select External filters in the left panel to add the script to the filters list. Give the entry a suitable name like toFileName and as command
|python3 /path/to/scripts/toFileName.py|
Predefined external filters[edit]
Name | Command | Description |
Sort | |sort| | sort is a sorting program for Unix-like systems. |
Sort/Uniq | |sort|uniq| | uniq removes duplicates after the input is sorted by sort. It is also a program for Unix-like systems included in mysys. |
Reverse lines | |tac| | |
Dos2unix | |dos2unix| | Converts DOS line breaks to Unix line breaks. It is also a program for Unix-like systems included in mysys. |
Tidy HTML | |tidy -utf8| | Improves the HTML with tidy program. |
Tidy convert in XHTML | |tidy -utf8 -i -w 80 -c -q -asxhtml| | Converts HTML to XHTML with tidy. |
Tidy HTML (perltidy) | |perltidy -b| | (strawberry) |
Strip empty lines | |egrep -v '^[ ]*$'| | Deleting empty lines using regular expressions with egrep. |
Render HTML in Text | lynx -force_html -dump %i | | |
PHP Beautifier | |php_beautifier -t| | Improves PHP code with indentation of one tab. |
Javascript Minify with jsmin | |/usr/share/bluefish/jsmin.py| | Minifies Javascript code with a Python script, which is provided by bluefish. |
CSS Minify with cssmin | |/usr/share/bluefish/cssmin.py| | Minifies CSS code with a Python script, which is provided by bluefish. |
CSS tidy | |csstidy --preserve_css=true -| | Optimises CSS code. |
Output box[edit]
The external commands can be reached through Tools → Outputbox.
Customising output box[edit]
For customising external commands you have to open the Preferences dialog either through Edit → Preferences or the Preferences button on the toolbar. Select Output parsers in the left panel.
There are seven columns for editing external filters:
- Enabled: If this is checked, you are able to reach that command through Tools → Filters.
- Name: The name of the command in menu.
- Pattern: Here is a regexp pattern send with the command.
- File #
- Line #
- Output #
- Command: Here is the command.
These are the options for the output box:
Input options | |
| | start with a | to send the input to the standard input |
%f | local file name (requires local file, cannot operate on selection) |
%i | temporary file name for input |
Output options | |
| | end with a | to read the output from the standard output |
%o | temporary file name |
%t | temporary file name for both input and output (for in-place-editing "filters, cannot operate on selection) |
Other options | |
%a | additional arguments that will be asked when this filter is activated |
%c | local directory of file (requires local file) |
%n | file name without path (available for all titled files) |
%u | URL (available for all titled files) |
%p | preview URL if basedir and preview dir are set in project settings, else identical to %u |
Predefined output parsers[edit]
Name | Command | Description |
make | |cd %c && make| | Runs the make build tool. |
weblint HTML-Check | |weblint '%f'| | |
tidy HTML-Check | |tidy -qe '%i'| | |
javac | |javac '%f'| | Compiles Java code. A JDK has to be installed. |
xmllint XML-Check | |xmllint --noout --valid '%f'| | |
PHP | |php '%f'| | Runs a PHP script. |
PHP syntax check | |php -l -q -f '%f'| | Cecks syntax and runs the PHP script. |
Perl syntax check | |perl -c '%f'| | Checks only the syntax of the Perl script. |
PHP Codesniffer | |phpcs --report=emacs '%f'| | |
pylint | |pylint '%f'| |