Page 1 of 1
overriding display of certain elements in Author View
Posted: Mon Jul 13, 2015 10:29 pm
by ttasovac
hi.
TEI uses <egXML> for marking up examples of TEI itself when writing documentation etc. I'm wondering whether it would be possible, while using the Author View, to somehow override all the children of <egXML> to display as a block element but not using the Author View's tags, but rather using clean XML a là Editor View?
In other words, I am not interested in controlling the -oxy-tags-color and -oxy-tags-background-color, but rather displaying "proper" xml in the Author View for the children of <egXML>.
Any tips would be greatly appreciated.
All best,
Toma
Re: overriding display of certain elements in Author View
Posted: Tue Jul 14, 2015 10:25 am
by Patrik
Hi Toma,
I once did something similar for DITA (didn't discard the approach - just postponed it):
xml sample code
Code: Select all
<xml-codeblock>
<Root>
<Element>Text</Element>
<Element>More Text</Element>
<Element/>
</Root>
</xml-codeblock>
css
Code: Select all
xml-codeblock {
display: block;
font-family: "Courier New", monospace;
}
xml-codeblock * * {
display: block;
padding-left: 2em;
}
xml-codeblock *:before {
content: '<' oxy_xpath('name()') '>';
background-color: #EFEFEF;
}
xml-codeblock *:after {
content: '</' oxy_xpath('name()') '>';
background-color: #EFEFEF;
}
xml-codeblock *:empty:before {
content: '<' oxy_xpath('name()');
}
xml-codeblock *:empty:after {
content: "/>";
}
Attributes are not supported yet...
Regards,
Patrik
Re: overriding display of certain elements in Author View
Posted: Tue Jul 14, 2015 12:12 pm
by ttasovac
many, many thanks, patrik for this hint. i added oxy_attributes() so now attributes display as well.
since all this is done through the css content property, i don't see how i could style element names, attributes and values differently — they all seem to have to be the same color. but having xml examples in the author view display as monochromatic xml will already be a big improvement for us.
all best,
toma
Re: overriding display of certain elements in Author View
Posted: Tue Jul 14, 2015 12:35 pm
by Patrik
To use different styles for the content you can use either different pseudo elements:
Code: Select all
xml-codeblock *:before(3) {
content: '<' oxy_name();
background-color: #EFEFEF;
color: blue;
}
xml-codeblock *:before(2) {
content: oxy_attributes();
background-color: #EFEFEF;
color: red;
}
xml-codeblock *:before(1) {
content: '>';
background-color: #EFEFEF;
color: blue;
}
or use oxy_label():
Code: Select all
xml-codeblock *:before {
content: '<' oxy_name() oxy_label(text, oxy_attributes(), styles, "color: red;") '>';
background-color: #EFEFEF;
color: blue;
}
But I don't see a reasonable way to assign different colors for attribut names and values with css only. You could do with it with a java plugin, though.
Regards,
Patrik
Re: overriding display of certain elements in Author View
Posted: Tue Jul 14, 2015 1:49 pm
by ttasovac
this is great. many thanks, once again, patrik!
Re: overriding display of certain elements in Author View
Posted: Tue Jul 14, 2015 4:56 pm
by alex_jitianu
Hi Toma,
I think that I should also mention the
text area form control, which right now can only edit the
text content of an element. Starting with version 17.1 (the next version) this form control will also be able to edit the entire XML content of an element (so also structure). So it will look like a small text mode editor inside the author view. You will get syntax highlight as in the text page as well as content completion.
Although it can't help you right now, I felt the need to mention it for future users reading this post. Other than that, I think Patrik described perfectly what can be done right now.
Best regards,
Alex
Re: overriding display of certain elements in Author View
Posted: Tue Jul 14, 2015 4:59 pm
by ttasovac
Thanks, Alex — that's great news. 17.1 will be my favorite update ever
All best,
Toma
Re: overriding display of certain elements in Author View
Posted: Tue Jul 14, 2015 7:58 pm
by Patrik
Hi Alex,
will the editor be as comfortable as the text mode of oXygen? I.e. supporting content completion, automatically add closing tag, automatic indention...?
Patrik
Re: overriding display of certain elements in Author View
Posted: Wed Jul 15, 2015 8:58 am
by alex_jitianu
Hi Patrik,
I hope so... It will have the features you've mentioned. But I can't guarantee that it will be completely the same experience because we also want to keep the component as lightweight as possible.
Best regards,
Alex
Re: overriding display of certain elements in Author View
Posted: Wed Jul 15, 2015 9:43 am
by Patrik
Sounds great! :D