In haml the following would produce the correctly nested HTML:
%p Hi There I'm inside this paragraph
%button I'm also inside this paragraph
Produces:
<p> Hi There I'm inside this paragraph <button>I'm also inside this paragrpah</button></p>
In Emblem.js if I do:
p Hi There I'm inside this paragraph
%button I'm also trying to be in the paragraph
It produces this:
<p> Hi There I'm inside this paragraph %button I'm also trying to be in the paragraph</p>
Does anyone know how to nest content and elements inside emblem.js?
p Hi There I'm inside this paragraph
button I'm also trying to be in the paragraph
without the % will do the trick
I can recommend checking out http://emblemjs.com/syntax/ , it's a great resource that briefly explains every possible use case.
Related
I am developing a pandoc markdown template for a journal whose final format needs sections to be unnumbered, that is, \section and children should become \section*.
I know that is sufficient to add {-} in the markdown next to the header title, but I want to force this behaviour and do not depend on users writing markdown correctly.
I tried with:
function Header(el)
el.classes = 'unnumbered'
return el
end
but it makes the headers disappear... I am totally new to LUA so bear with me.
How should I proceed?
Success!
I needed curly brackets around the class to denote a "table"
function Header(el)
el.classes = {'unnumbered'} -- curly brackets were missing here
return el
end
or use an index since classes is a List:
function Header(el)
el.classes[1] = 'unnumbered' -- classes is a List
return el
end
I'm trying to create a list in Markdown. As I've read in some documentation, if I write this Markdown code:
My list
* first item
* second item
* third item
Not in the list
I would get as result the same as if I write this in HTML:
<p>My list</p>
<li>
<ul>first item</ul>
<ul>second item</ul>
<ul>third item</ul>
</li>
<p>Not in the list</p>
I use Atom as editor and its Markdown previewer and everything is OK, but when I use pandoc to convert my Markdown file as follows:
pandoc test.md -o test.odt
what I get is this:
My list * first item * second item * third item
Not in the list
Where am I doing wrong?
There are two possible solutions to your problem:
Add a blank line between the paragraph and the list (as #melpomene mentioned in a comment).
My list
* first item
* second item
* third item
Not in the list
Leave out the blank line and tell Pandoc to use commonmark as the input format rather than the default, markdown.
pandoc -f commonmark -o test.odt test.md
The "problem" is that the Atom editor uses a CommonMark parser and, by default, Pandoc uses an old-school Markdown parser which mostly follows these rules and the reference implementation (markdown.pl). In fact, the Commonmark spec specifically acknowledges this difference:
In CommonMark, a list can interrupt a paragraph. That is, no blank
line is needed to separate a paragraph from a following list:
Foo
- bar
- baz
<p>Foo</p>
<ul>
<li>bar</li>
<li>baz</li>
</ul>
Markdown.pl does not allow this, through fear of triggering a list
via a numeral in a hard-wrapped line:
The number of windows in my house is
14. The number of doors is 6.
If you want common behavior among your tools, then you need to only use tools which follow the same behavior.
I'm rendering texts in a prawn pdf report and would like to define the exact spacing after a paragraph.
I found :leading, which helps to define the line height, but nothing to define the spacing after a new paragraph (within the same cell or bounding box).
So far I have not found out how to define the spacing as such, but I still think I found the problem why the space was too large.
I add the statement
puts content.dump
to my class to print the content on the console.
In the cases where I had a paragraph in the content, the paragraph was replaced by \n\n.
Example:
<p>Text</p><p>Text</p>
is changed to
"Text\n\nText\n\n"
As I anyway use an html sanitizer method to remove undesired html tags, I could extend the method with the following:
res = content.gsub(/\n{2,2}/, "\n")
res = res.gsub(/\n{3,}/, "\n\n")
This solved the problem for me.
I have an XML doc which is massive - a short example is below to illustrate formatting. What I want to do is find all the text in the doc which is not within a tag and delete it - so I am left with just a list of the data...
So here is the original:
51.639973121-2.161205923
112.0
<time>2017-02-19T11:26:45Z</time>
51.639902964-2.161258059
111.6
<time>2017-02-19T11:26:46Z</time>
51.639834484-2.161310529
111.6
<time>2017-02-19T11:26:47Z</time>
51.639765501-2.161366101
111.6
<time>2017-02-19T11:26:48Z</time>
51.639697859-2.161426451
111.8
<time>2017-02-19T11:26:49Z</time>
And once formatted - it will become:
<time>2017-02-19T11:26:45Z</time>
<time>2017-02-19T11:26:46Z</time>
<time>2017-02-19T11:26:47Z</time>
<time>2017-02-19T11:26:48Z</time>
<time>2017-02-19T11:26:49Z</time>
How is this possible???
The following expression will select all text but time tags:
^(?!<time>[^<]+<\/time>).*\R
It works only if the tags are on a new line, like in you example input.
See the demo
I have the following repeated piece of the web-page:
<div class="txt ext">
<strong class="param">param_value1</strong>
<strong class="param">param_value2</strong>
</div>
I would like to extract separately values param_value1 and param_value2 using Xpath. How can I do it?
I have tried the following constructions:
'//strong[#class="param"]/text()[0]'
'//strong[#class="txt ext"]/strong[#class="param"][0]/text()'
'//strong[#class="param"]'
none of which returned me separately param_value1 and param_value2.
P.S. I am using Python 2.7 and the latest version of Scrapy.
Here is my testing code:
test_content = '<div class="txt ext"><strong class="param">param_value1</strong><strong class="param">param_value2</strong></div>'
sel = HtmlXPathSelector(text=test_content)
sel.select('//div/strong[#class="param"]/text()').extract()[0]
sel.select('//div/strong[#class="param"]/text()').extract()[1]
// means descendant or self. You are selecting any strong element in any context. [...] is a predicate which restricts your selection according to some boolean test. There is no strong element with a class attribute which equals txt ext, so you can exclude your second expression.
Your last expression will actually return a node-set of all the strong elements which have a param attribute. You can then extract individual nodes from the node set (use [1], [2]) and then get their text contents (use text()).
Your first expression selects the text contents of both nodes but it's also wrong. It's in the wrong place and you can't select node zero (it doesn't exist). If you want the text contents of the first node you should use:
//strong[#class="param"][1]/text()
and you can use
//strong[#class="param"][2]/text()
for the second text.