Page 1 of 1

author mode codeblock / coderef in dita

Posted: Fri Mar 23, 2012 4:20 am
by pmac
i find myself inserting lots of code blocks in files (as separate coderef text files), and every time i do that i find myself doing the following

- starting in author mode
- content assist to insert codeblock
- content assist to insert coderef
- the coderef is now "unhelpful" in author mode
- switch to text mode
- find the auto-inserted <coderef/> and manually insert href=""
- drag a text file from the project between the quotes ... which does the right thing with the relative path
- back to author mode and continue a few lines

sounds mundane, but i'm editing lots of files with code snippets and it's getting pretty old.

- dragging a file over the codeblock/coderef doesn't do what i want (i.e. insert the href of the coderef) .. or at least i can't figure out how to make it do that.
- The attributes view is not helpful - copy/paste inserts an absolute file URI

So ...

- is there a way of doing this in author mode?
- or are the templates for the auto-inserted elements editable somewhere so i can just insert the href="" in there so every coderef gets an href (it's not useful without as far as i can tell)

THANKS

PMac

Re: author mode codeblock / coderef in dita

Posted: Fri Mar 23, 2012 11:43 am
by Radu
Hi,

Basically the content completion inserts only the elements which are declared as required by the associated DTDs (or schemas).

But you have a good workaround by using code templates:

Go to the Oxygen Preferences->Editor / Templates / Code Templates page and define a new code template.
Set as the body of the code template the following XML fragment:

Code: Select all

<codeblock><coderef href="">${caret}</coderef></codeblock>
Then in the Author page when you invoke the content completion window you should now be able to use the new code template to insert the XML fragment. After the insertion, just press the "ALT-ENTER" shortcut to open the in-place attributes editor dialog and select a value for the @href attribute (the chooser will make the value relative by default).

The attributes view can also be used to insert relative references to URLs (but the feature is quite hidden). In the right top corner of the view there is a small expansion arrow which shows a value chooser for the currently selected attribute.

This suggestion you made:
dragging a file over the codeblock/coderef doesn't do what i want (i.e. insert the href of the coderef) .. or at least i can't figure out how to make it do that.
is quite interesting, I will add an improvement request for this and the forum thread will be updated when it gets implemented.

By the way, we have another feature request logged in to show in the Author page the referenced file's content expanded as read-only (just like when you are making a conref). Would you consider this also to be useful to you?

Regards,
Radu

Re: author mode codeblock / coderef in dita

Posted: Fri Mar 23, 2012 11:36 pm
by pmac
Thanks Radu

adding a template alleviates quite a lot of the extra clicking ... i will do it for <link> and <xref> also. I find it (with the set of files i have) easier to toggle to text and drag a file in the right spot rather than use the attribute dialog. Native file dialogs are horrible things, but the search (find) dialog in oxygen is very efficient.

Expanding out file content would be good as confirmation you have the right one. Having an easy editor toggle (if there isn't one already) to expand / hide included content might be a useful companion for that - so you could see either all content, or just the "content being edited in xml". Without that, big includes might make the structure harder to see.

thanks

PMac

Re: author mode codeblock / coderef in dita

Posted: Tue Jul 10, 2012 5:32 pm
by Radu
Hi,

Oxygen 14.0 which was released a couple of weeks ago should insert a coderef when dragging files in a codeblock.

Regards,
Radu