Invalid indentation in Jade - jade4j

I'm getting below error while trying to insert a script file in Jade
Can anyone please help?
form(method='post', action='/posts/add', enctype="mutilpart/form-data")
.form-group
label Title:
input.form-control(name='title', type='text')
.form-group
label Category:
select.form-control(name='category')
each category, i in categories
option(value='#{category.title}') #{category.title}
.form-group
label Body:
textarea.form-control(name='body', id='body')
.form-group
label Main Image:
input.form-control(name='mainimage', type='file')
.form-group
label Author:
select.form-control(anme='author')
option(value='Brad Traversy') Brad Traversy
option(value='John Doe') John Doe
input.btn.btn-defalut(name='submit',type='submit',value='Save')
script(src='/ckeditor/ckeditor.js')
script
| CKEDITOR.replace('body');

You have an syntax error here. Replace
script
CKEDITOR.replace('body');
by
script.
CKEDITOR.replace('body');

Related

I need help about Title in sweetalert

I have an error (or nothing shows) on put a Text with quotes when I refer to inches ( " or ยดยด)
swal({
text: ' Product X 10" '
})
or
swal({
text: ' Product X 10' '
})
What might be the cause of this?

Change line spacing for RMD abstract?

Is it possible to change the line spacing for the abstract specified in my YAML header to single space, while leaving the rest of the document in double space? My YAML is below:
output: pdf_document
number_sections: true
title: |
| My Title
author:
- Me
header-includes:
- \usepackage{setspace}\doublespacing
- \usepackage{float}
abstract: "My abstract"
keywords: "My keywords"
date: "`r format(Sys.time(), '%B %d, %Y')`"
geometry: margin=1in
fontsize: 12pt
spacing: double
fig_caption: yes
indent: true
---
I've tried wrapping the abstract like so, but it did not work:
abstract:
- \usepackage{setspace}\singlespacing
"My abstract"
- \end{singlespacing}
The abstract is automatically wrapped, so it is enough to use \singlespacing before it:
---
output: pdf_document
number_sections: true
title: |
| My Title
author:
- Me
header-includes:
- \usepackage{setspace}\doublespacing
- \usepackage{float}
abstract: \singlespacing My abstract which has to be long enough to take multiple
lines otherwise one does not see the effect of single-spacing.
keywords: "My keywords"
date: "`r format(Sys.time(), '%B %d, %Y')`"
geometry: margin=1in
fontsize: 12pt
fig_caption: yes
indent: true
---
## R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for
authoring HTML, PDF, and MS Word documents. For more details on using R Markdown
see <http://rmarkdown.rstudio.com>.
Result:

How to grap the content between <span class="attribute first">AUTHOR: </span>Stepfen King

I have the following source:
<p class="byline"><span class="attribute first">AUTHOR: </span>Stephen Butts<span class="attribute">DATE: </span><span class="monthText" style="margin-right:4px;">MAY</span>2015<span class="attribute">SUBJECT: </span>Options</p>
I want to use the XPath to grap the text/content of the AUTH: Stephen King. I've tried using the following but it doesn't work:
authors = tree.xpath('//span[#class="attribute first"]/text()', namespaces=ns)
How to do that?
You need a text of p, but not span. Try:
//p[#class="byline"]/text()[2]
or
//span[#class="attribute first"]/following-sibling::text()[1]

R Markdown YAML "Scanner error: mapping values..."

I have noticed this issue when knitting all file types (html, pdf, word). To make sure there's not an issue specific to my program, I went ahead and ran the default .rmd file you get when you create a new markdown. In each case, it does knit correctly, but I always see this at the end. I have searched online and here but cannot seem to find an explanation
Error in yaml::yaml.load(string, ...) :
Scanner error: mapping values are not allowed in this context at line 6, column 19
Error in yaml::yaml.load(string, ...) :
Scanner error: mapping values are not allowed in this context at line 6, column 19
Error in yaml::yaml.load(string, ...) :
Scanner error: mapping values are not allowed in this context at line 4, column 22
Here is my default YAML
---
title: "Untitled"
author: "Scott Jackson"
date: "April 20, 2017"
output: word_document
---
Line 4, column 22 is the space between the 7 and "
I'm not sure where Line 6, column 19 is, but that line is the dashes at the bottom
Any ideas?
Thank you.
I get this error when trying to add a table of contents to the YAML:
title: "STAC2020 Data Analysis"
date: "July 16, 2020"
output: html_notebook:
toc: true
However, if I put html_notebook: on to a separate line then I don't get the error:
title: "STAC2020 Data Analysis"
date: "July 16, 2020"
output:
html_notebook:
toc: true
I do not know why this formatting makes a difference, but it allowed my document to knit and with a table of contents.
I realize this question has gone unanswered for awhile, but maybe someone can still benefit. I had the same error message and I realized I had an extra header command in my yaml. I can't reproduce your exact error, but I get the same message with different line/column references with:
---
title: "Untitled"
author: "Scott Jackson"
date: "April 20, 2017"
output: output: word_document
---
Error in yaml::yaml.load(string, ...) :
Scanner error: mapping values are not allowed in this context at line 4, column 15
Calls: <Anonymous> ... parse_yaml_front_matter -> yaml_load_utf8 -> <Anonymous>
Execution halted
Line 4 column 15 seems to refer to the second colon after the second "output".
I received this error when there was an indentation in the wrong place:
For example, the indentation before header-includes as seen in the example code below caused the error
---
title: "This is a title"
author: "Author Name"
header-includes:
.
.
.
---
When you remove the indentation, the following code below did not produce the error:
---
title: "This is a title"
author: "Author Name"
header-includes:
.
.
.
---
Similarly to Tim Ewers I also got this error when I added a TOC to the YAML:
title: "My title"
date: "April 1, 2020"
output:
pdf_document: default
toc: true
html_document: paged
However, the solution I found was to remove "default", this allowed me to knit the document without an error:
title: "My title"
date: "April 1, 2020"
output:
pdf_document:
toc: true
html_document: paged
I guess this error happens on your content instead of your yaml block.
Because there is no extra content display so I will give a minimal example.
> library(yaml)
> library(magrittr)
> "
+ ---
+ title: 'This is a title'
+ output: github_document
+ ---
+
+ some content
+ " %>%
+ yaml.load()
$title
[1] "This is a title"
$output
[1] "github_document"
It works well. And here is another example.
> "
+ ---
+ title: 'This is a title'
+ output: github_document
+ ---
+
+ some content
+ some content: some content
+ " %>%
+ yaml.load()
Error in yaml.load(.) :
Scanner error: mapping values are not allowed in this context at line 8, column 13
The errors happens at line 8. Because there is a key-value pair not at yaml block.
yaml.load is not enough smart for me.
The temporal solution for me is just extract all lines above the second ---.
> text <- "
+ ---
+ title: 'This is a title'
+ output: github_document
+ ---
+
+ some content
+ some content: some content
+ "
> library(xfun)
> read_lines(text,n_max = 5) %>%
+ yaml.load()
$title
[1] "This is a title"
$output
[1] "github_document"
I had a similar problem and made a request in the YAML and rticles help pages:
https://github.com/viking/r-yaml/issues/92
https://github.com/rstudio/rticles/issues/363
I know this is a 5 year old question but I just got this same error as I was missing a colon
---
title: ''
output:
pdf_document
includes:
before_body: before_body.tex
---
should have been
---
title: ''
output:
pdf_document:
includes:
before_body: before_body.tex
---
and while that doesn't strictly answer the example given, I hope it will help future sufferers of this error message.

Parsing an XML feed using Nokogiri isn't working

This is my code:
doc= Nokogiri::HTML(open("http://www.cincinnatisun.com/index.php?rss/90d24f4ad98a2793", 'User-Agent' => 'ruby'))
search=doc.css('item')
if !search.blank?
search.each do |data|
title=data.css("title").text
link=data.css("link").text
end
end
but I did not get the link.
Several things are wrong:
if !search.blank?
won't work because search would be a NodeSet returned by doc.css. NodeSet's don't have a blank? method. Perhaps you meant empty??
title=data.css("title").text
isn't the correct way to find the title because, like in the above problem, you're getting a NodeSet instead of a Node. Getting text from a NodeSet can return a lot of garbage you don't want. Instead do:
title=data.at("title").text
Changing the code to this:
require 'nokogiri'
require 'open-uri'
doc= Nokogiri::HTML(open("http://www.cincinnatisun.com/index.php?rss/90d24f4ad98a2793", 'User-Agent' => 'ruby'))
search=doc.css('item')
if !search.empty?
search.each do |data|
title=data.at("title").text
link=data.at("link").text
puts "title: #{ title } link: #{ link }"
end
end
Outputs:
title: Ex-Bengals cheerleaders lawsuit trial to begin link:
title: Freedom Center Offering Free Admission Monday link:
title: Miami University Band Performing in the Inaugural Parade link:
title: Northern Kentucky Man To Present Colors At Inauguration link:
title: John Gumms Monday Forecast link:
title: President Obama VP Biden sworn in officially begin second terms link:
title: Colerain Township Pizza Hut Robbed Saturday Night link:
title: Cold Snap Coming to Tri-State link:
title: 2 Men Arrested After Police Chase in Northern Kentucky link:
The link won't work because the XML is malformed, which, in my experience, is unbelievably common on the internet because people don't take the time to check their work.
The fix is going to take massaging the XML prior to Nokogiri receiving the content, or to modify your accessors. Luckily, this particular XML is easy to work around so this should help:
require 'nokogiri'
require 'open-uri'
doc = Nokogiri::HTML(open("http://www.cincinnatisun.com/index.php?rss/90d24f4ad98a2793", 'User-Agent' => 'ruby'))
search = doc.css('item')
if !search.empty?
search.each do |data|
title = data.at("title").text
link = data.at("link").next_sibling.text
puts "title: #{ title } link: #{ link }"
end
end
Which outputs:
title: Ex-Bengals cheerleaders lawsuit trial to begin link: http://www.cincinnatisun.com/index.php/sid/212072454/scat/90d24f4ad98a2793
title: Freedom Center Offering Free Admission Monday link: http://www.cincinnatisun.com/index.php/sid/212072914/scat/90d24f4ad98a2793
title: Miami University Band Performing in the Inaugural Parade link: http://www.cincinnatisun.com/index.php/sid/212072915/scat/90d24f4ad98a2793
title: Northern Kentucky Man To Present Colors At Inauguration link: http://www.cincinnatisun.com/index.php/sid/212072913/scat/90d24f4ad98a2793
title: John Gumms Monday Forecast link: http://www.cincinnatisun.com/index.php/sid/212070535/scat/90d24f4ad98a2793
title: President Obama VP Biden sworn in officially begin second terms link: http://www.cincinnatisun.com/index.php/sid/212060033/scat/90d24f4ad98a2793
title: Colerain Township Pizza Hut Robbed Saturday Night link: http://www.cincinnatisun.com/index.php/sid/212057132/scat/90d24f4ad98a2793
title: Cold Snap Coming to Tri-State link: http://www.cincinnatisun.com/index.php/sid/212057131/scat/90d24f4ad98a2793
title: 2 Men Arrested After Police Chase in Northern Kentucky link: http://www.cincinnatisun.com/index.php/sid/212057130/scat/90d24f4ad98a2793
All that done, you can write your code more clearly like:
require 'nokogiri'
require 'open-uri'
doc = Nokogiri::HTML(open("http://www.cincinnatisun.com/index.php?rss/90d24f4ad98a2793", 'User-Agent' => 'ruby'))
doc.css('item').each do |data|
title = data.at("title").text
link = data.at("link").next_sibling.text
puts "title: #{ title } link: #{ link }"
end
Interestingly enough, now the sample page appears to have its links fixed.
According to http://nokogiri.org/tutorials/searching_a_xml_html_document.html something like:
#doc = Nokogiri::XML(File.read("feed.xml"))
#doc.xpath('//xmlns:link')
should do the job. But be aware, that your provided xml snippet isn't a valid xml feed at all (no root element, item tag not opened - only closed etc.). The code assumes the xml feed looks i.e.
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<item>
<title>Atom-Powered Robots Run Amok</title>
<link>http://example.org/2003/12/13/atom03</link>
</item>
</feed>
And extracts:
<link>http://example.org/2003/12/13/atom03</link>
as result. Please try to to look at the documentation/reference first, if you have problems like this. If you tried something and it didn't worked like you would expect, than you can consult stackoverflow with actual code - that makes it easier to understand your problem & provide help.

Resources