Wrap/unwrap selected text in an element

Are you missing a feature? Request it's implementation here.
iatttmp

Wrap/unwrap selected text in an element

Post by iatttmp » Thu Mar 31, 2011 5:34 pm

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.

adrian
Posts: 2533
Joined: Tue May 17, 2005 4:01 pm

Re: Wrap/unwrap selected text in an element

Post by adrian » Thu Mar 31, 2011 6:08 pm

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
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

iatttmp

Re: Wrap/unwrap selected text in an element

Post by iatttmp » Thu Mar 31, 2011 6:31 pm

Thanks, Adrian.

This happens a lot to me :oops: - wanting features that great products already include.

Tim

Chaa006
Posts: 4
Joined: Thu Sep 12, 2013 8:21 pm

Re: Wrap/unwrap selected text in an element

Post by Chaa006 » Mon Sep 21, 2015 2:16 pm

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

adrian
Posts: 2533
Joined: Tue May 17, 2005 4:01 pm

Re: Wrap/unwrap selected text in an element

Post by adrian » Mon Sep 21, 2015 3:51 pm

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
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

RBVanDyke
Posts: 43
Joined: Wed Feb 11, 2015 11:25 pm
Location: San Francisco, California USA
Contact:

Re: Wrap/unwrap selected text in an element

Post by RBVanDyke » Fri Jun 16, 2017 8:33 pm

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

Radu
Posts: 6328
Joined: Fri Jul 09, 2004 5:18 pm

Re: Wrap/unwrap selected text in an element

Post by Radu » Mon Jun 19, 2017 10:31 am

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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Drew
Posts: 5
Joined: Thu Oct 25, 2018 7:14 pm

Re: Wrap/unwrap selected text in an element

Post by Drew » Thu Oct 25, 2018 7:34 pm

Code: Select all

Ctrl-e
and

Code: Select all

Alt-Shift-x
work, generally. But

Code: Select all

Alt-Shift-x
does not seem to be the inverse of

Code: Select all

Ctrl-e
- it does not undo what

Code: Select all

Ctrl-e
does. At least not in appearance.

Start with this, which is shown with the

Code: Select all

p
tags rendered as O2 full tags.

Code: Select all

<p>Some text</p>

Code: Select all

Ctrl-e
, choose comment. That gives:

Code: Select all

<comment><p>Some text</p></comment>
, which is shown with the

Code: Select all

comment
tags rendered as O2 tags, surrounding the text

Code: Select all

<p>Some text</p>
. That's expected.

Code: Select all

Alt-Shift-x
then gives:

Code: Select all

<p>Some text</p>
, but that is shown (in Author mode) as text - the

Code: Select all

p
tags are not rendered as O2 tags. And in Text mode I can see that the result was in fact this:

Code: Select all

<p>Some text</p>
This looks like a bug to me. I wrap and unwrap all the time. In particular, I wrap with tag

Code: Select all

comment
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

Code: Select all

<p>Some text</p>
end up as

Code: Select all

<p>Some text</p>
?

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.

Radu
Posts: 6328
Joined: Fri Jul 09, 2004 5:18 pm

Re: Wrap/unwrap selected text in an element

Post by Radu » Fri Oct 26, 2018 8:55 am

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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Drew
Posts: 5
Joined: Thu Oct 25, 2018 7:14 pm

Re: Wrap/unwrap selected text in an element

Post by Drew » Thu Nov 01, 2018 6:49 pm

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).

Radu
Posts: 6328
Joined: Fri Jul 09, 2004 5:18 pm

Re: Wrap/unwrap selected text in an element

Post by Radu » Fri Nov 02, 2018 9:54 am

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:

Code: Select all

<!--<b>Gladiolus</b>-->
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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Drew
Posts: 5
Joined: Thu Oct 25, 2018 7:14 pm

Re: Wrap/unwrap selected text in an element

Post by Drew » Sat Nov 03, 2018 1:29 am

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:

Code: Select all

<!--<b>Gladiolus</b>-->
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.

Post Reply