I would like to split my title in my ColumnChart into 2 (or more) lines.
(see https://developers.google.com/chart/interactive/docs/gallery/columnchart)
I tried using the pipe ("|") symbol as follows, but it doesn't work, neither does "\n".
var options = {"title":"My first line | \n this should be the second line!"};
Thank you for your attention!
And in javascript, in your chart options variable, just add \n where you want a break, like:
vAxis: { title: "Line one of the title\nLine two of the title" }
The Google Visualization API charts don't support line breaks in the titles. I am given to understand that support for using HTML is in the pipeline (which would allow you to use <br /> tags for line breaks), so keep an eye out for announcements to that effect in the Visualization API group.
The \n option seems to work now. I have just used:
var options = {title: 'Heading\nSub-heading'}
and got this output:
Heading
Sub-heading
Perhaps this is a recent addition.
In case someone need this tips for add break line on ColumnName (DataTableChart) you can use <br> but need to add on chart options : { allowHtml: true }
You need to add ASCII code 10.
In Ruby I used the following:
Label = first_line_string + 10.chr + second_line_string
Related
I am using bookdown for a documentation which is outputted with bookdown::gitbook and bookdown::pdf_book.
In my Rmd files, I am using a div to wrap around notes and warnings styled with a css file. For example:
<div class="note">
This is a note.
</div>
Obviously, HTML and CSS is ignored when generating the PDF file. I was wondering if there is a way to "inject" a small script that would replace the div with, for example, a simple prefix text.
Or, is there another way to have it formatted in HTML and in the PDF without littering my file by adding something lengthy every time like:
if (knitr::is_html_output(excludes='epub')) {
cat('
<div class="note">
This is a note.
</div>
')
} else {
cat('Note: This is a note.')
}
I could also style blockquotes as described here but it is not an option as I still need blockquotes.
The appropriate way to do this is to use a fenced div rather than inserting HTML directly into your markdown and trying to parse it later with LUA. Pandoc already allows you to insert custom styles and process them to both file types. In other words, it will take care of creating the appropriate HTML and LaTeX for you, and then you just need to style each of them. The Bookdown documentation references this here, but it simply points to further documentation here, and here.
This method will create both your custom classed div in html and apply the same style name in the LaTeX code.
So, for your example, it would look like this:
::: {.note data-latex=""}
This is a note.
:::
The output in HTML will be identical to yours:
<div class="note">
<p>This is a note.</p>
</div>
And you've already got the CSS you want to style that.
The LaTeX code will be as follows:
\begin{note}
This is a note.
\end{note}
To style that you'll need to add some code to your preamble.tex file, which you've already figured out as well. Here's a very simple example of some LaTeX that would simply indent the text from both the left and right sides:
\newenvironment{note}[0]{\par\leftskip=2em\rightskip=2em}{\par\medskip}
I found this answer on tex.stackexchange.com which brought me on the right track to solve my problem.
Here is what I am doing.
Create boxes.lua with following function:
function Div(element)
-- function based on https://tex.stackexchange.com/a/526036
if
element.classes[1] == "note"
or element.classes[1] == "side-note"
or element.classes[1] == "warning"
or element.classes[1] == "info"
or element.classes[1] == "reading"
or element.classes[1] == "exercise"
then
-- get latex environment name from class name
div = element.classes[1]:gsub("-", " ")
div = div:gsub("(%l)(%w*)", function(a, b) return string.upper(a)..b end)
div = "Div"..div:gsub(" ", "")
-- insert element in front
table.insert(
element.content, 1,
pandoc.RawBlock("latex", "\\begin{"..div.."}"))
-- insert element at the back
table.insert(
element.content,
pandoc.RawBlock("latex", "\\end{"..div.."}"))
end
return element
end
Add pandoc_args to _output.yml:
bookdown::pdf_book:
includes:
in_header: latex/preamble.tex
pandoc_args:
- --lua-filter=latex/boxes.lua
extra_dependencies: ["float"]
Create environments in preamble.tex (which is also configured in _output.yml):
I am using tcolorbox instead of mdframed
\usepackage{xcolor}
\usepackage{tcolorbox}
\definecolor{notecolor}{RGB}{253, 196, 0}
\definecolor{warncolor}{RGB}{253, 70, 0}
\definecolor{infocolor}{RGB}{0, 183, 253}
\definecolor{readcolor}{RGB}{106, 50, 253}
\definecolor{taskcolor}{RGB}{128, 252, 219}
\newtcolorbox{DivNote}{colback=notecolor!5!white,colframe=notecolor!75!black}
\newtcolorbox{DivSideNote}{colback=notecolor!5!white,colframe=notecolor!75!black}
\newtcolorbox{DivWarning}{colback=warncolor!5!white,colframe=warncolor!75!black}
\newtcolorbox{DivInfo}{colback=infocolor!5!white,colframe=infocolor!75!black}
\newtcolorbox{DivReading}{colback=readcolor!5!white,colframe=readcolor!75!black}
\newtcolorbox{DivExercise}{colback=taskcolor!5!white,colframe=taskcolor!75!black}
Because I have also images and tables within the boxes, I run into LaTeX Error: Not in outer par mode.. I was able to solve this issue by adding following command to my Rmd file:
```{r, echo = F}
knitr::opts_chunk$set(fig.pos = "H", out.extra = "")
```
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 am using a third party indexing service (Swiftype) to search through my database. The returned records contains a property called highlight. This simply adds <em> tags around matching strings.
I then bind this highlight property in Ember.JS Handlebars as such:
<p> Title: {{highlight.title}} </p>
Which results in the following output:
Title: Example <em>matching</em> text
The browse actually displays the <em> tags, instead of formatting them. I.e. Handlebars is not identifying the HTML tags, and simply printing them as a string.
Is there a way around this?
Thanks!
Handlebars by default escapes html, to prevent escaping, use triple brackets:
<p> Title: {{{highlight.title}}} </p>
See http://handlebarsjs.com/#html-escaping
Ember escapes html because it could be potentional bad code which can be executed. To avoid that use
Ember.Handlebars.SafeString("<em>MyString</em>");
Here are the docs
http://emberjs.com/guides/templates/writing-helpers/
if you've done that you could use {{hightlight.title}} like wished,...
HTH
Here is the code:
<div>23 Anywhere Ave<br />Someplace<br />Somewhere 1234</div>
I want to scrape the resulting three lines
23 Anywhere Ave<br />Someplace<br />Somewhere 1234</div>
into separate columns. I can scrape the first string (23 Anywhere Ave) by setting <div> as the front marker and <br /> as the back marker.
Get stuck after that. I've tried setting the front marker as <div>(?=)<br />), /<div>(?=)<br />)/ (Outwit apparently require / / when making a regex statement), and <div>/(?=)/<br />)to get the second value but no luck.
I realise that regex is not suitable for parsing HTML, but this post indicates that it's OK in certain contexts within the Outwit architecture.
In automators/scrapers put this Separator: br
Then in List of Labels: Street,City,ZipCode
Br,
Eusebio.
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.