Importing Tagged Text with Filters

From Scribus Documentation Project

Jump to: navigation, search

Contents

Introduction

Creating a document with a consistent look of the paragraph formatting is much easier than you may think. The secrets for success are document templates, paragraph styles, and text filters, not to mention article submitters who don't mind just a little extra work for the good of the project you are working on. The basic idea is that you tag text to be imported in a way that makes use of paragraph styles you have already set up. Once you have tagged the text it will then be possible to create a text import filter which will automatically apply paragraph styles to the imported text using the tags in the text file. Before we get to the tagging process, let's step back to the beginning of setting up the document, since this is integral to being able to use these tags.

Creating a Document Template

If you have a need to use the same layout repetitively it's a good idea to create a document template. Within a document template you will have all your paragraph and line styles set up and all static graphics and texts so that you will be able to concentrate on setting up the new content instead of creating the non-changing parts of the publication each time you make a new issue. The details of creating a document template can be found in the chapter Opening, Creating, Saving...ENDNOTE. For our purposes here, we will just outline the process.

The document template is done the very same way you will create any other document in Scribus. The only difference is that you will not want to have anything single-issue-specific in the template so you will for example leave all the text frames for articles empty. What you want to have in the template are all the items that will stay untouched from one issue to another. One such item is paragraph styles you use to set up the articles, so that you can guarantee that all the text paragraphs will be formatted the same way in every issue of your publication.

Setting up Paragraph Styles

Paragraph style creation is described in depth in the chapter Working With Styles.ENDNOTE In the sample document I have set up three paragraph styles called H1, P1 and P2. H stands for headers and the style H1 should be applied to all article headers. The P styles are for paragraphs. P1 will not have the first line indented and should be used for the first paragraph after the header. The P2 style has the first line indented and will be applied to all other paragraphs in the article.

Image:Creating_pstyles.png

Setting Up the Text Filter

Now it is time to create the text filter you will be using when importing articles to your layout. The idea behind the filter is that you can filter the incoming text, then carry out some Scribus operation. In this example we will be applying paragraph styles (H1, P1 and P2) to the text based on the tags that can be found in the imported text. The filters will work by having your writers prepend every paragraph they write with \P1 and \P2 and headers with \H1. Here the \P1, \P2 and \H1 are the tags and will be used to apply paragraph styles, and the tags themselves will be stripped from the text in the process. Using tag names similar to style names helps you keep track of what you are doing.

Image:Article_text.png

At this point we'll go on to create the filter. The filter editor can be accessed from Edit > Get Text... or from the context menu (right click on the frame) then choose > Get Text.... This brings up a file dialog where at the bottom you will see a drop down box for the importer. The default importer for a text file is an importer which will get the text to a text frame as it is. Here we need to select the Text Filter importer from this drop down menu. Now browse to your article file, select it, and click Open, which bring up the text filter editor.

Image:File_dialog.png

Now with the Create filter editor open, create the first filter part, which will apply paragraph style H1 to all paragraphs that have been tagged (prepended) with \H1. From the first drop down box select Apply. This will change the look of the filter part to match the apply function. The second drop down box will show Paragraph Style, and the third drop down box should be empty and writable. The third writable drop down box is reserved for the paragraph style that will be applied. It is possible to enter a non-existent paragraph style, in which case Scribus will create that style – this illustrates that if you wish you can set up filters before you create the styles. Here we wish to use one of the styles we just created, and as a convenience, the existing paragraph styles can be found in the drop down box. Select H1 from there or type it in the text area of the drop down box. Since we know that the texts we will be using are prepended with tags, select paragraphs starting with from the fourth drop down box. In the fifth drop down box type in the tag name \H1. The last drop down box should be left to its default remove match, to remove the tag from the text when it is being imported.

Repeat the above steps for the paragraph styles P1 and P2 using the tag names \P1 and \P2. You can create a new filter part from the plus sign on the right side of every existing filter part – as you might suspect, clicking the minus sign will delete an associated filter part. Once you have setup all three filter parts you should type in the name for the filter in the text field at the bottom right corner. This will save the filter so that it will be available from the drop down menu in the top right corner. Note that currently text filters are not document-specific and are not saved with the document, but rather with your Scribus settings.

Image:Text_filter.png

Save the Document Template

Once you have set up the paragraph styles, save your template (File > Save as Template), calling your template document a name that suits you. Before saving the document, remember to clear the content of the text frame you used for the filter creation.

Image:Creating_doc_template.png

Using the document template and the filter

Now we are ready to use our new template. When it is time to start working on a new issue of your publication, select File > New from Template from the menu to bring up this dialog:

Image:Nft.png

Once you have opened the template, create a text frame or select one of the existing text frames in the template if you included those in your template design. Right click on the text frame, then choose Get Text... from the context menu. In the dialog choose the Text Filter importer and choose your appropriately tagged text file. In the filter editor choose the filter you created from the top right corner's drop down box if it is not already visible and click OK. At this point you should soon have a nicely formatted article inside your text frame and you can start fine tuning the layout.

Image:Imported_article.png

Personal tools