Is there a way to set letter-spacing in raphael js text? It can be done easily in CSS, how can I do it in raphael? Any hacks would also do..
Paper.print() has a letter-spacing attribute:
var txt = r.print(10, 50, "O HAI", r.getFont("Comic Sans"), 30, 'middle', 1).attr({fill: "#fff"});
^
this is the letter spacing
See the docs on that.
Note that this needs "cufon-style" font files to be included and will render a non-selectable path object instead of real text.
It can be done with normal css. take a look here : http://tutorials.jenkov.com/svg/text-element.html . The css is applied to svg too.
Here's a live demo that shows svg text with letter-spacing.
Related
I use Django 1.11 for my blog.
I illustrate all acticles in my first page by a title, an image and a few words.
For the few words, I'm using this method :
{{post.text|safe|linebreaks|truncatewords:"50"}}
I use a text editor and sometimes, I use for example italic text :
<i/>Italic text</i>
Let's imagine the value of truncatewords is on "1". It means it returns :
<i/>Italic
There is my problem. Some HTML tags are still opened. It means that the italic text never end and It will be applied for the rest of the code.
Do you know if a trick or workaround exists ?
Thank you.
I want to make custom grammar like Wiki and how can I do it in React and without dangerouslySetInnerHTML?
For example:
"hello this is simple string [linkToSomewhere] {this is where bold goes}"
becomes
<div>
hello this is simple string <Link where="linktoSomewhere"/> <Bold string="this is where bold goes"/>
</div>
like this
I found way to parse custom markdown to array but found no way to insert it as react component array is like
link[0] = "linkToSomewhere"
bold[0] = "this is where Bold goes"
Thank you in advance!
There are a few Markdown libraries available for React. Check out:
react-markdown: https://rexxars.github.io/react-markdown/
react-remarkable: https://github.com/acdlite/react-remarkable
And here's a whole host of other libraries that can translate your Markdown document into a nicely rendered HTML: https://react.rocks/tag/Markdown
And in order to learn the Markdown syntax, there are a few cheat sheets available, such as:
http://assemble.io/docs/Cheatsheet-Markdown.html
https://guides.github.com/pdfs/markdown-cheatsheet-online.pdf
I have a situation where I need to differentiate two calls by the path in the source of a HTML. This is how the img tag looks like
<img src="/folder/12280218/160024536.images.jpg" />
I am planning to alter the source to
<img src="/folder/12280218/160024536.images.jpg/1" />
observe the "/1" at the end of src
I need this so that I can change the flow in the controller when I am serving this image.
This is what I have tried until now.
my $string = '<p><img src="/folder/12280218/160024536.images.jpg" /></p>';
$string =~ s/<img\s+src\=\"(.*)"\s+\/><\/p>/<img src\=\"$1\/1" \><\/p>/g;
This is working as long as the $string looks like this.
In our application, user has the ability to alter the HTML input using CKEditor.
He can alter the image tag by adding width="800" before or after the src attribute. I want the regular expression to handle all these situations.
Please let me know how to proceed.
Thanks in advance.
Replace :
(<img.*src="[^"]*)(".*\/>)
by
$1/1$2
Demo here
Edit : Changed the regex to handle situations with other attributes (like the "width" part)
I don't know much about HTML or imacros.
I'm trying to make an imacros script that takes a screenshot of an image on the page, but the website has a navigation bar which when imacros takes the screenshot covers half of the image.
How can I create an imacros script to remove this navigation bar from my screen?
In inspect elements, I can get rid of it by removing:
So how can I remove this in imacros please?
Thank you
Use Javascript for this.
To remove element by ID use this code.
var id = window.document.getElementById("page-container");
id.parentNode.removeChild(id);
Instead of "page-container" put your ID you want to remove
To remove elements by class
Use this:
var collection = window.content.document.getElementsByClassName("Class-name");
Array.prototype.forEach.call(collection, function(node) {
node.parentNode.removeChild(node);
});
It's possible with imacros and url goto as iim script. Or you can use pure javascript as js file in your imacros.
Example with url goto and class name:
URL GOTO=javascript:var<SP>delclass=window.content.document.getElementsByClassName("class<SP>name");Array.prototype.forEach.call(delclass,function(node){node.parentNode.removeChild(node)});
I have the following output.
<img width='70' height='70' class='centreimg' src="http://localhost/aktivfitness_new/assets/images/centre/centre1.jpg" />
There are same outputs with centre2.jpg etc.
Now I want to replace this centre1.jpg to hover.jpg when I hover.
But when I use the following it becomes centre1hover.jpg
$(".centreimg").mouseover(function() {
var hoverimg = $(this).attr("src").match(/[^\.]+/) + "hover.jpg";
...
Something is wrong with match(/[^.]+/) + "hover.jpg part.
How can I do this?
Thanks in advance.
Don't you think this would be easier:
var newSrc = oldSrc.replace(/[^\/\.]+\./, 'hover.');
Anyway: you shouldn't use Javascript for hovers =) If there is another way: use it. Not only is it a bad practice, it's also not user friendly: when the image loads when you hover, the user will see a 'flash' because the entire image still has to be loaded = not pretty.