|
||||
|
NAMEMagicpoint-EZ - Preprocessor for "Magicpoint" presentation viewer
VERSIONv0.02
DOCUMENTATIONThe latest documentation on this module is always available at http://teachmeperl.com/magicpoint-ez.html.
DOWNLOADSAt the present time, this program has not yet had its first general release. It is currently being made available to a few selected individuals for testing, before being released on CPAN (http://cpan.org). Watch for updates on its status at http://teachmeperl.com/magicpoint-ez.html.
OVERVIEW
SYNOPSISFirst convert the *.mg file to *.mgp using: mgp-ez presentation.mg > presentation.mgp Then run Magicpoint on the *.mgp file as usual: mgp presentation.mgp
Explanationmgp-ez takes a filename like presentation.mg as an argument, and writes output for a presentation.mgp file, for viewing with Magicpoint (see http://www.mew.org/mgp). The input file is called *.mg to indicate that it is nearly ready to be displayed with Magicpoint, but not quite -- it still needs some additional processing by Magicpoint-EZ before it will become a *.mgp file. Magicpoint (http://www.mew.org/mgp) is great, and free, and open source, which are all wonderful properties. But for people who want to create non-trivial presentations, it's too cumbersome for efficient use. This program alleviates that problem.
Slides of YAPC 2004 talk on Magicpoint-EZThe Author gave a talk at the 2004 North American "Yet Another Perl Conference" on this software, whose slides (at http://teachmeperl.com/publications/YAPC.04/mgpez.pdf) illustrate its benefits and provide many examples of its usage.
Demonstration #1: Title PageThe mgp-ez program lets you create a Magicpoint presentation much more easily, and with the option of using many powerful new features. For instance, consider a page whose basic design is described in the first section below. It's created by storing in a *.mg file the required text, Magicpoint directives, and special mgp-ez tags, shown in the second section. This file is then processed by mgp-ez to create the *.mgp file, shown in the third section, that tells Magicpoint how to lay out the page. The *.mg file to describe the page only requires 532 characters, but the associated *.mgp file for Magicpoint's use takes 1221! Somebody has to do 130% more work; why should it be you? Please examine the image of this page, to get the full appreciation for how many stylistic changes are involved, and how nice the result looks. It's available at http://teachmeperl.com/Page1.jpg, or reproduced below, if the your document format supports images. You may click the image to make it larger.
1. Basic Design for Title PageTitle Sub-title Part II in series <IMAGE HERE> Author URL of Company Web-Site Email address Phone Number Date of Printing Complication: I want lots of color and font changes on this page!
2. Page Composed in *.mg fileHere's the *.mg file that creates the above page, complete (and replete) with color and font changes, as well as other formatting conveniences that aren't provided by Magicpoint itself. (Described below). NOTE: As detailed in Sample .mg2mgprc file, style codes starting with C_, F_, and S_ are respectively for color, font, and size changes. The user can also use the actual color-names (e.g., mediumseagreen), if desired, but many will prefer abbreviations for frequently used names. <TITLE>, <SUBTITLE>, <PARTS_TITLE>, <PARTS_TEXT>, and other bracketed words that aren't colors, fonts, or size requests, are user-defined styles, described below.
3. Output from mgp-ez that Creates PageYou may have thought the *.mg file looked complicated, but here's what you would have had to type on your own (excluding comments) to get the same result directly with Magicpoint.
Demonstration #2: Source CodeHere's another sample page, which shows off some of the source-code oriented features of mgp-ez, including its ability to render comments differently.
Sample Source-Code PageYou may click the image (at http://teachmeperl.com/mgp_demos/data_validation.jpg) to make it larger.Here's the *.mg file, of 682 bytes:
And here's the corresponding *.mgp file, of 1,918 bytes:
DESCRIPTIONThe purpose of Magicpoint-EZ is to make it much easier for the user to prepare Magicpoint presentations, through use of a highly configurable preprocessor that allows user-defined styles to be easily applied to text. Styles are defined by adding custom style definitions to the .mg2mgprc configuration file, which is distributed with some sample styles that the Author uses. Other features make it easier to acquire and prepare text obtained from operating system commands, and control how it is displayed. For example,
recursive file inclusion is provided by the In addition,
To make it easier to proofread demonstrations, %pause directives can be filtered out using the command mgp_nopause, so each page can be viewed in one glance.
ImplementationThis software is provided as a script called mgp-ez, that relies on a MGPez.pm module that's provided separately. This distribution requires the user to employ traditional Perl techniques to download and install the module before using it, and is provided for those familiar with that routine. Once the customary Perl-module installation has been accomplished for the mgp-ez version, the scripts are used identically.
SubroutinesThe program makes us of many subroutines. Those that start with the prefix "mgp_" are Magicpoint-specific. But there are also others (include, skipper, code_command, etc.) that are of general text-processing applicability, which you may like to use in other applications (e.g., I'm using them in a custom POD pre-processor). Ultimately, this body of software
will be distributed on the CPAN (www.cpan.org), probably under
the name This is a preliminary version that is implemented as a single Perl script, which can be invoked under the following names (if it's multiply linked on installation): skipper, include, po2pod, process_command, process_code, _mgp_force_gaps, add_newlines, mgp_nopause, mgp-emgp-ez Most importantly, the mgp-ez invocation implements the following cascading filter, so you don't have to go to all the trouble of indenting those lines correctly yourself: 8-} <INPUT_HERE> include skipper code_command mgp_rm_comment mgp_pages mgp_styles mgp_tinygap mgp_nopause _mgp_force_gaps add_newlines mgp_squeeze_gaps <OUTPUT HERE>
STYLE DEFINITIONSThe user is allowed considerable freedom in choosing names for styles,
such as BIG, Bold, Red47, Hot_Pink, Centered_and_Italic, and even
such names as Of course, other special characters could be added to this list on request, if anybody finds this set too restrictive. A collection of pre-fabricated style definitions is provided in the configuration file, using a naming convention that the Author finds helpful. For example, the following is a style definition of the color-changing
variety, whose leading C_G %fore "gold" A style definition of the alignment ( A_C %center %leftfill This facility is needed because there's no native way in Magicpoint to undo a style change.
Style TagsIn the body of the presentation itself, a style change is requestaed using angled-brackets around a style name, and optionally the text to be rendered in that style (if the "undo" behavior is desired). For example, in the mgp view, all words will be <C_G>golden from here on To request the automatic application of the "undo" style, you can embed the text to be rendered within the style tag, so long as you have provided the optional undo line in the definition. (NOTE: The implementation of the "undo" style is not quite mature yet; in particular, there's a problem with extraneous blank lines appearing when two or more appear in a row; I'll fix this eventually.) For example, given the style definition for centering shown above, the following text would get the results shown below (although the lines might not look centered in this document):
Sample Style DefinitionsA_C %center A_C-R %center %rightfill
Input<A_C>CENTERED NEXT <A_C-R centered>next more
OutputCENTERED NEXTCentered Next More
Additional Sample Style DefinitionsA_C %center
Input<A_C These words are centered> and these will be on a separate line, left-filled
OutputThese words are centered and these will be on a separate line, left-filled
Predefined Styles
ColorsFor convenience, hundreds of color names are predefined in the program itself. If you wish, you can use these directly, and avoid defining any color "styles" of your own. But you need to know the color names before you can use them, so a special invocation of the script is provided for this purpose. For example, to see all the available colors with red in their names, you can do the following: mgp_grep_colors 'red' darkred => #8B0000 indianred => #CD5C5C mediumvioletred => #C71585 orangered => #FF4500 palevioletred => #DB7093 red => #FF0000 red1 => #FF0000 red2 => #EE0000 red3 => #CD0000 red4 => #8B0000 With this information, you'd be free to use these color styles in your presentation like so: Sunset shifts hues from <orangered>orange to<darkred>dark red
Font sizesPredefined font-size requests ranging from <S_2> (or <S_02>) through <S_5.75> (or S_05.75) to <S_16> in quarter-point increments are provided. They can be used like so, to make the word BIG relatively large, and shorty relatively small: <S_8>With music by the world-famous <S_14>BIG<S_5>shorty! Or, with an indented line, the RESET style can be used to automatically reinstate the original size: With music by the world-famous <S_14>BIG<RESET>shorty!
Vertical spacingPredefined style requests that generate vertical-gaps of sizes ranging from <V_03> through <V_95>, also return the vgap setting to DEFAULT_VGAP, but these styles are meant for controlling the vertical spacing between collections of adjacent text lines, whereas these directives merely insert a single vertical gap where requested.
User-Defined VariablesSee the configuration file documentation for complete information on defining your own variables, for use in style definitions. For example, the following style definition changes the foreground
color to "turquoise",
and then its "undo" style switches to the
foreground color that's specified in the
definition of LHEAD %font "bull1", size 6.0, leftfill, fore "turquoise" %font "default", fore "$FORE_COLOR", leftfill
The RESET StyleThe single biggest problem with Magicpoint, from the point of view of somebody who wants to do intra-line changes of text attributes, is that there's no way to "undo" a change, to revert to the orignal settings. The RESET style helps with this problem, by allowing the user to request the reinstatement of the default attributes for the current indentation level.
ExampleThis is a <ITALIC>Level 1<RESET> heading This is a <ITALIC>Level 2<RESET> heading This is a <GREEN><ITALIC>Level 2<RESET><GREEN> heading Because the first line above is indented by one tab, it will have certain attributes assigned to its text, such as a "bold" font at size 6. The <ITALIC> style request changes the font, and then the <RESET> request reinsates the "bold" font and size 6. The appropriate "resetting" would also occur for the 2nd-level bullet, although the particulars of font, size, color, etc., might well have been defined differently in the configuration file. Note however that in the 3rd line, the <RESET> style would undo the changes to both the GREEN color and the ITALIC font, requring the user to reinstate the GREEN color to achieve the effect of undoing only the font change to ITALIC.
DIRECTIVESThe mgp-ez program implements several directives, that enhance or extend those provided already by Magicpoint. Unlike style definitions, directives don't have undo information, because their job is not to change, and then (optionally) change again (for "undoing"), display parameters. Instead, they filter, collect, generate, or reformat text, which may involve harvesting data and applying formatting codes. The mgp-ez directives are all of the same form: a word terminated by a %.
Yes, that's exactly backwards from the %word format used by
Magicpoint itself, so that if Next, we'll examine each of the Magicpoint-EZ directives in turn.
|
|||
|