Build a new filter plugin
Version 1 (Alexis Bienvenüe, 11/12/2012 09:22 pm)
1 | 1 | h1. Build a new filter plugin |
|
---|---|---|---|
2 | 1 | ||
3 | 1 | AMC has two built-in source file types : LaTeX and AMC-TXT. You can add some more... |
|
4 | 1 | ||
5 | 1 | h2. Files to be written |
|
6 | 1 | ||
7 | 1 | To define a new file type named @mytype@, you need to create two perl modules with the following files: |
|
8 | 1 | <pre> |
|
9 | 1 | $HOME/.AMC.d/plugins/mytype/perl/AMC/Filter/register/mytype.pm |
|
10 | 1 | $HOME/.AMC.d/plugins/mytype/perl/AMC/Filter/mytype.pm |
|
11 | 1 | </pre> |
|
12 | 1 | ||
13 | 1 | Have a look at the corresponding files for type @plain@ (LaTeX files) and the parents modules (@AMC/Filter/register.pm@ and @AMC/Filter.pm@) to see how they are built. The @AMC::Filter::register::mytype@ module is used to register this new file type in AMC, and the @AMC::Filter::mytype@ module is used to process an input file written with our new type to a LaTeX file. As an example, the processing part of @AMC::Filter::mytype@ only copies the file: |
|
14 | 1 | <pre> |
|
15 | 1 | sub filter { |
|
16 | 1 | my ($self,$input_file,$output_file)=@_; |
|
17 | 1 | copy($input_file,$output_file); |
|
18 | 1 | } |
|
19 | 1 | </pre> |
|
20 | 1 | ||
21 | 1 | h2. Pack the code |
|
22 | 1 | ||
23 | 1 | If you want to publish your module so that another user can use it, make a ZIP archive with the @mytype@ tree from your @$HOME/.AMC.d/plugins/@ directory. That's it! |