Page 1 of 1
Wrap/unwrap selected text in an element
Posted: Thu Mar 31, 2011 5:34 pm
by iatttmp
When you're madly re-purposing content from a horrible xml source with an indecipherable schema, it's really handy to be able to mark a bunch of text and just wrap in an arbitrary tag. Structured Framemaker has this feature. The suggestion dialog should pop up to assist while typing the new tag, but there should be no restriction on choices since the document is probably invalid in the first place.
oXygen already has a (sort of) unwrap function. If you delete a tag, the closing tag often disappears as well. The behavior is not perfectly consistent and could be made explicit with an nice "unwrap" command.
Re: Wrap/unwrap selected text in an element
Posted: Thu Mar 31, 2011 6:08 pm
by adrian
Hello,
Oxygen already has these functions/actions in Text mode.
To wrap the selected content, right click on the selection and from the contextual menu choose Refactoring -> Surround with Tags(Ctrl+E). You can choose a tag name from the proposed list or simply type your own.
To unwrap, right click on an element start or end tag and from the contextual menu choose Refactoring -> Delete Element Tags(Alt+Shift+X).
Regards,
Adrian
Re: Wrap/unwrap selected text in an element
Posted: Thu Mar 31, 2011 6:31 pm
by iatttmp
Thanks, Adrian.
This happens a lot to me
- wanting features that great products already include.
Tim
Re: Wrap/unwrap selected text in an element
Posted: Mon Sep 21, 2015 2:16 pm
by Chaa006
Adrian, that is very helpful (I have been searching the Help system in vain to try to find out how to achieve that) but it will not allow me to wrap a tag with attributes. For example, while Ctrl-E allows me to wrap 'name' around (e.g., 'Charles Thorndyke') to yield <name>Charles Thorndyke</name>, I actually need to wrap 'name indexterm="Thorndyke,~Charles"' to yield <name indexterm="Thorndyke,~Charles">Charles Thorndyke</name>. How (if at all) can that be accomplished, please ? Including the attribute:value pair greys out the 'OK' button.
Philip Taylor
Re: Wrap/unwrap selected text in an element
Posted: Mon Sep 21, 2015 3:51 pm
by adrian
Hello Philip,
The Surround with Tags(Ctrl+E) action is meant only for tagging content (just XML element tags without attributes).
So, why not tag the content with CTRL+E, press the left arrow twice to move the caret inside the inserted tag and continue typing the attribute name and value
e.g.
1. Select the text => Charles Thorndyke| (| = caret, blue = selection)
2. Tag it (Ctrl+E) type "name", press OK=> <name>Charles Thorndyke|</name> (| = caret, blue = selection)
3. Press the left arrow twice to position the caret inside the tag => <name|>Charles Thorndyke</name> (| = caret)
4. Insert a space in the tag and type in the attribute name and value => <name indexterm="Thorndyke,~Charles">Charles Thorndyke</name>
If you want to re-use the tagged content both in text and in the tagged attribute value, Find/Replace with regexp could be the solution.
Regards,
Adrian
Re: Wrap/unwrap selected text in an element
Posted: Fri Jun 16, 2017 8:33 pm
by RBVanDyke
Howdy:
The good news is that the CTRL+e shortcut is exactly what I'm looking for.
The less good news is that it took me two days to find it. That's because I searched oXygen XML Editor (19) online help, and tried filtering Options > Preferences > Menu Shortcut Keys -- for the word wrap.
Don't know if there's a way to alias surround and wrap. Perhaps easier in the OLH than in the Preferences. Key point being that oXygen had the feature, I wanted to find it, but couldn't until I finally came over here to the forum.
Cheers & hope this helps,
Riley
SFO
Re: Wrap/unwrap selected text in an element
Posted: Mon Jun 19, 2017 10:31 am
by Radu
Hi Riley,
I understand, sorry for the inconvenience. We'll try to improve the menu shortcuts search to also allow us to define various extra keywords for actions.
Regards,
Radu
Re: Wrap/unwrap selected text in an element
Posted: Thu Oct 25, 2018 7:34 pm
by Drew
and
work, generally. But
does not seem to be the inverse of
- it does not undo what
does. At least not in appearance.
Start with this, which is shown with the
tags rendered as O2 full tags.
, choose
comment. That gives:
Code: Select all
<comment><p>Some text</p></comment>
, which is shown with the
tags rendered as O2 tags, surrounding the text
. That's expected.
then gives:
, but that is shown (in Author mode) as text - the
tags are not rendered as O2 tags. And in Text mode I can see that the result was in fact this:
This looks like a bug to me. I wrap and unwrap all the time. In particular, I wrap with tag
and later unwrap that.
We are just now moving from Arbortext to Oxygen, and Oxygen seems better so far, but this problem makes it almost unusable for me. What am I missing? How to correctly wrap and unwrap, without having an XML text() node (i.e., content of an element) such as
end up as
?
I'm sure that Oxygen must have a way to simply wrap and unwrap correctly (I hope so). I assume I just haven't found it yet. Thanks.
Re: Wrap/unwrap selected text in an element
Posted: Fri Oct 26, 2018 8:55 am
by Radu
Hi Drew,
I agree the "Delete Element Tags" should behave better in this situation, it's an action we thought will be used more for XML elements and not for XML comments.
I usually use in this particular case our "Toggle Comment" action (Command-Shift-Comma). It allows you to comment a selected area or if the caret is inside a comment to un-comment it.
Regards,
Radu
Re: Wrap/unwrap selected text in an element
Posted: Thu Nov 01, 2018 6:49 pm
by Drew
I was told about Backspace and Delete, in this context. That seems to DTRT to unwrap, when the cursor immediately follows the element you want to remove (unwrap). I'm using that now (but it does require positioning the cursor after the element). That shortcut doesn't seem to correspond to a menu item anywhere, but perhaps it should (for discovery).
Re: Wrap/unwrap selected text in an element
Posted: Fri Nov 02, 2018 9:54 am
by Radu
Hi Drew,
Not sure what unwrap situation you are referring to.
For example if in a DITA <p> element you have an XML comment like this:
then in the Author mode you try to use delete or backspace on the comment's start and end markers, you will not get the <b> as an XML element. To properly unescape the comment's content you will still need to use the "Toggle Comment" approach I previously suggested.
Regards,
Radu
Re: Wrap/unwrap selected text in an element
Posted: Sat Nov 03, 2018 1:29 am
by Drew
Radu wrote:Hi Drew,
Not sure what unwrap situation you are referring to.
For example if in a DITA <p> element you have an XML comment like this:
then in the Author mode you try to use delete or backspace on the comment's start and end markers, you will not get the <b> as an XML element. To properly unescape the comment's content you will still need to use the "Toggle Comment" approach I previously suggested.
Regards,
Radu
Right. Backspace/delete doesn't help with XML comments. It does with XML elements. It seems that the only thing that wraps/unwraps a comment is comment-toggling.