google-code-prettify xml indention - google-code-prettify

I have added line breaks in a generated xml doc.
<aa>"\n"
<bb>some text etc.</bb>"\n"
</aa>"\n"
this should end up as:
<aa>
<bb>some text etc.</bb>
</aa>
Is this possible with google-code-prettify - or should I do it myself in the code that generates the xml?
Thanks in advance

Prettify can style source code, but it does not re-indent or break lines.
It will preserve tags in your code so, so you can indent your code using line-breaks or you can use HTML layout to do that as in
<style>
code.prettyprint { display: block; white-space: pre-wrap }
div.el {margin-left: 2em}
</style>
<code class="prettyprint">
<div class=el><aa><div class=el><bb>...</bb></div></aa></div>
</code>
The <div class=el> uses margin-left to indent by a certain amount, and the pre-wrap causes line to wrap within the indented block.

Related

Nested / Compounded roles: apply multiple roles to overlapping text

In my custom.css file I have,
.bold {
font-weight: bold;
}
.red {
color:red;
}
And in my _.rst file,
.. role:: bold
.. role:: red
But if I try to nest/compound them, only the outermost role takes effect, e.g.
:bold:`:red:`This is only bold``
This is only bold
Is there a way to combine these effects without defining a new (combined) role?
you can use a custom css class directive:
.. cssclass:: boldred
bold red text
and update the css to format the boldred class
Roles are defined that the can not be nested.
Neither HTML nor LaTeX, as backends, support overlapping of styles.

Can I adress a element and a child without retyping the parent in scss?

Let's assume our html looks something like this:
<a>
<span class="title">Foo</span>
<span class="black-color-important">Bar</span>
Baz
</a>
Let's say .black-color-important stays always black. .title has a color assigned.
On hover, the normal text in the link and the title should switch colors to the $primary-color.
My SCSS for it looks like this:
a:hover, a:hover .title {
color: $primary-color;
}
Is there a better way? Or with other words is there a way, that I don't have to retype a:hover?
(If it would help, I don't care if it's a:hover > .title or a:hover .title in my case the .title would always be a direct child, but I tried to keep the question as open as possible)
Note: this is just an abstract example, not the real use case for it.
If the state of child element depends of its parent state, than you can't write styles without retyping the parent in scss.
But if you want to set a regular styles to a child, you can use BEM methodology and don't retype parent name.
div.parent
div.parent__child
.parent {}
.parent__child {}

XPATH that does extract style background color RGB value?

Can someone tell me an XPATH that does extract background color RGB values, or whole style, then I will remove unneeded data using Excel find/replace.
Been able to extract car color names using XPATH //div[#class='colorName']
<div class="colours" style="background-color: #040404; height: 30px; width: 130px; margin: 7px"></div>
<div class="colorName">Obsidian Black</div>
Source page: http://www.carwale.com/mercedesbenz-cars/e-class/e63amg-3049/
You can use the combination of substring-after() and substring-before():
substring-before(substring-after(//div[#class="colours"]/#style, "background-color: "), ";")
Works for me in the chrome console:
> $x('substring-before(substring-after(//div[#class="colours"]/#style, "background-color: "), ";")')
"#040404"

Overriding a variable value for a specific element

I have a small project, where i first tried Zurb Foundation framework, heavily using SASS variables for customization, and i got one problem.
I use their block-grid extensively, and i need to change $block-grid-default-spacing: variable value to rem-calc(2), but only inside a #gallery element, and leave it at default value elsewhere.
If it helps, i use simple code for my gallery (with some irrelevant Smarty templating)
<section id="gallery-container" class="row">
<ul id="gallery" class="clearing-thumbs small-block-grid-2 medium-block-grid-3 large-block-grid-4" data-clearing>
{foreach from=$offer->photos->get() item=photo}
<li>
<img src="{$photo->image->thumb(true, 295, 230, 5)}" alt="{$offer->title->get()}"/>
</li>
{/foreach}
</ul>
</section>
From the docs on the Foudation page, I think they have a mixin that is available to create your own block-grid. The following was take from http://foundation.zurb.com/docs/components/block_grid.html:
.your-class-name {
#include block-grid(
// This controls how many elements will be on each row of the block grid. Set this to whatever number you need, up to the max allowed in the variable.
// Available options: 1-12 by default, and false.
$per-row: 3,
// This controls how much space is between each item in the block grid.
// Use a variable or any pixel or em values.
$spacing: $block-grid-default-spacing,
// This controls whether or not base styles come through, set to false to leave out.
$base-style: true
);
}
Using block-grid mixin turned out to be a great idea that solved my problem. That's how my code looked like in the end:
#gallery
#media #{$small-up}
+block-grid(2, rem-calc(3))
#media #{$medium-up}
+block-grid(3, rem-calc(3))
#media #{$large-up}
+block-grid(4, rem-calc(3))

What is ">ul" means in SASS?

Here is the SASS code part:
#main-nav{
>ul{
blahblah
}
}
So I want to know the exact mean of the string ">ul" means? I cannot find it in the SASS manual.
Furthermore, can it be translated to stylus?
This the CSS syntax to select the child of an element. See this reference for more on how it works:
This selector matches all elements that are the immediate children of
a specified element. The combinator in a child selector is a
greater-than sign (>). It may be surrounded by whitespace characters,
but if it is, Internet Explorer 5 on Windows will incorrectly treat it
as a descendant selector. So the best practice is to eschew whitespace
around this combinator.
#main-nav {
> ul {
color: red;
}
}
The same in CSS:
#main-nav > ul { color: red }
About > selector you can read here http://net.tutsplus.com/tutorials/html-css-techniques/the-30-css-selectors-you-must-memorize/ (#8)

Resources