XMetaL Tips and Tricks
Derek Read October 31, 2008 at 10:23 pm
Script Example: Override "Smart Paste" for DITA <codeblock> and <pre> ElementsOctober 31, 2008 at 10:23 pmParticipants 1Replies 0Last Activity 13 years, 8 months ago
All XMetaL Author “DITA Editions” including XMetaL Author Enterprise
XMetaL Author Enterprise come with a feature called “Smart Paste” that is functional whenever DITA documents are being edited. This feature kicks in any time you press Ctrl+V (the standard Windows paste function) while you are editing a DITA document.
“Smart Paste” works well most of the time and attempts to do things like find the next legal location for markup that is being pasted when a user pastes into an otherwise invalid location. It attempts to wrap text that is being pasted into a document with appropriate elements, often the paragraph element p, in order to allow the text to be inserted. Without this functionalty users would be hearing a lot more beeps indicating what they are trying to do is not allowed. When pasting from a web browser (HTML), Word or Excel document some simple mappings are performed to try to preserve the look and feel of the original content (bold, italics, tables, lists, etc) by inserting equivalent DITA elements.
In some cases you may not wish to have your text or markup interpreted in this special way. There may be other cases for this but pasting into two elements in particular can be tricky. These elements are codeblock and pre.
When pasting markup (anything that includes elements) into codeblock or pre elements the markup is interpreted by “Smart Paste” and in most cases you end up with your new markup being inserted outside these elements and possibly altered in an unacceptable fashion. In addition, if the text you are pasting simply consists of multiple lines (text with one or more line breaks, like programming source code for example) the “Smart Paste” feature inserts each line into the document separately, separating each one with a p element.
A scripting workaround is available for this and can be thought of as being similar (in a way) to the Microsoft Word “Paste Special” feature. This script allows you to override the “Smart Paste” functionality in the XMetaL Author DITA editions, telling the application to paste your text into the document without performing any special interpretation on it.
* Licensed Materials – Property of JustSystems, Canada, Inc.
* (c) Copyright JustSystems Canada, Inc. 2008
* All rights reserved.
* The sample contained herein is provided to you “AS IS”.
* It is furnished by JustSystems Corporation as a simple example and has not been
* thoroughly tested under all conditions. JustSystems Canada, Inc., therefore, cannot
* guarantee its reliability, serviceability or functionality.
* This sample may include the names of individuals, companies, brands and products
* in order to illustrate concepts as completely as possible. All of these names are
* fictitious and any similarity to the names and addresses used by actual persons or
* business enterprises is entirely coincidental.
Script Installation and Usage:
Important: This script is being made available for use by experienced users, administrators and/or IT departments (people that manage the installation and configuration of an XMetaL deployment). Test this script in a test environment (non-production machine) before distributing to end users. This is unsupported demo code.
1. Download DITAsmartPasteOverride.zip
2. Unzip the file to an empty folder of your choice.
3. Open DITAsmartPasteOverride.mcr in a text editor and review the documentation it contains for usage, warnings and installation instructions.
- You must be logged in to reply to this topic.