Let's say I have:
<span th:if="${#fields.hasErrors('firstName')}" class="color--error" th:errors="*{firstName}"></span>
How do I escape the text if the error text contains HTML? I know for normal text, we can use th:utext.
As of 3.0.8-SNAPSHOT, Thymeleaf-Spring has th:uerrors.
See this GitHub issue for the discussion: https://github.com/thymeleaf/thymeleaf-spring/issues/153
And this change log for 3.0.8: http://forum.thymeleaf.org/Thymeleaf-3-0-8-JUST-PUBLISHED-td4030687.html
th:errors is just a shortcut. You still use th:utext for this, you just have to manually output your errors. In your case, the code could look something like:
<div th:if="${#fields.hasErrors('firstName')}" th:each="err: ${#fields.errors('firstName')}" th:utext="${err}" class="color--error" />
Related
Is it possible to somehow tell pandoc to carry the names of styles from original HTML to .docx?
I understand that in order to tune the actual styles, I should be using reference.docx file generated by pandoc. However, reference.docx is limited to what styles it has to: headings, body text, block text, etc.
I'd like to:
specify "myStyle" style in the input HTML (via a "class" attribute, via any other HTML attribute or even via a filter code written in Lua),
<html>
<body>
<p>Hello</p>
<p class="myStyle">World!</p>
</body>
</html>
add a custom "myStyle" to reference.docx using Word,
run a html->docx conversion an expect pandoc generate a paragraph element with "myStyle" (instead of BodyText, which I believe it sets by default), so the end result looks like this (contents of word/document.xml inside the resulting output.docx was cut for brevity):
<w:p>
<w:pPr>
<w:pStyle w:val="BodyText" />
</w:pPr>
<w:r>
<w:txml:space="preserve">Hello</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:pStyle w:val="myStyle" />
</w:pPr>
<w:r>
<w:txml:space="preserve">World!</w:t>
</w:r>
</w:p>
There's some evidence styleId can be passed around, but I don't really understand it and am unable to find any documentation about it.
Doc on filtering in Lua states you can access attrs when manipulating a pandoc.div, but it says nothing about whether any of the attrs will be interpreted by pandoc in any meaningful way.
Finally, found what I needed – Custom styles. It's limited, but better than what I arrived earlier, and of course much better than nothing at all :)
I'll leave a step-by-step guide here in case anyone stumbles upon a similar question.
First, generate a reference.docx file like this:
pandoc --print-default-data-file reference.docx > styles.docx
Then open the file in MS Word (I was using a macOS version) you'll see this:
Click the "New style..." button on the right, and create a style to your liking. In my case I made change the style of text to be bold, in blue color:
Since I am converting from HTML to DOCX, here's my input.html:
<html>
<body>
<div>Page 1</div>
<div custom-style="eugene-is-testing">Page 2</div>
<div>Page 3</div>
</body>
</html>
Run:
pandoc --standalone --reference-doc styles.docx --output output.docx input.html
Finally, enjoy the result:
Is it possible to provide spaces or new line or line breaks on gmail compose on URL schemes. I tried both /n or stringByAddingPercentEscapesUsingEncoding, but space or lines breaks are not reflecting.
googlegmail:///co?subject=subject&body= "\n\n\n textfirstname"
This is not an issue with iOS or url-scheme. You need to use html tag to set new line. For HTML there are <br/> or <br /> which are used to break line. Use this tag instead of \n.
As per you code it should looks like this:
Whatever<br/>text<br/>you<br/>want
I hope this will be useful to you.
Part of the code in "routes.rb",
...
post '/csr' do
text = PkiSupport::display_csr('/etc/pki/subordinate_ca.csr')
erb :download_csr, :locals => { :csr => text }
end
In "PkiSupport.rb"
...
def display_csr(csr_file)
text = `more #{csr_file}`
return text
end
In "download_csr.erb"
...
<form id="csr-form" action="<%= url "/subordinate_ca/csr" %>" method="post">
<h4>csr</h4>
<textarea cols="80" rows="36" name="csr">
<%= csr %>
</textarea>
</form>
The idea is very simple, when user chooses "/csr", shell command "more ..." will be executed and the output string shown in the textarea of a form.
It does show up correctly, but contains extra preceding string (below), which is anything ahead of "-----BEGIN...". So how to prevent it?
::::::::::::::
/etc/pki/subordinate_ca.csr
::::::::::::::
-----BEGIN CERTIFICATE REQUEST-----
MIIFATCCAukCAQAwaDETMBEGCgmSJomT8ixkARkWA2NvbTETMBEGCgmSJomT8ixk
ARkWA3h5ejEQMA4GA1UECgwHWFlaIEluYzESMBAGA1UECwwJTWFya2V0aW5nMRYw
FAYDVQQDDA0xMC4xMC4xMzAuMTU4MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC
CgKCAgEAruWYRn7mjZkHeD+PPLpMSBRoYnLKNvYMte9XneFDh1TItLolYhM4bmWX
gewKOO9+kNY21CoVu1jYZ3q9WitgJlS3tMHPhc6IjuY9DfQ58aeJaZHO8+ISE3Op
l6xNcaxOeHXMlVgdeX4ouyzB2ykJVhu1KtE+XTKilUu6nIrH6ETHrxelBs36Hu1q
...
Thanks.
Most likely, your culprit line of code is this one:
text = `more #{csr_file}`
That code forks and runs the standard Unix more program. Some versions of more will detect if they're run from another program, and output things slightly differently. That's what you're seeing here.
The quickest fix would be to change that line to
text = `cat #{csr_file}`
cat doesn't try to be as smart as more and will give you just the contents of the file.
Now, that said, there's no reason why your Ruby program needs to run a separate program just to read the contents of a file - Ruby has support for reading files directly. So the best fix would be to change that line to:
text = File.read(csr_file)
That will be faster and more portable.
I have set all parameters as discribed in http://kavita-ganesan.com/rouge-howto. But I get zero values of precision recall and f-1. Please, Help me what can i do?
If you have set all parameters right and are not getting any error while running rouge then probably you are doing the following mistake while making your summary files in html format.
rouge does not handle whitespaces properly
thus
<a name="1">[1]</a> <a href="#1" id= 1>
<a name="1">[1]</a> <a href="#1" id=1>
are not the same
In the first case you will not be shown any error but the output will be zero. In second case you get the right output.
Hope this helps..
The settings.xml file should look something like this:
<ROUGE_EVAL version="1.5.5">
<EVAL ID="1">
<PEER-ROOT>systems</PEER-ROOT>
<MODEL-ROOT>models</MODEL-ROOT>
<INPUT-FORMAT TYPE="SPL" />
<PEERS>
<P ID="1">peer.txt</P>
</PEERS>
<MODELS>
<M ID="A">modelA.txt</M>
<M ID="B">modelB.txt</M>
<M ID="C">modelC.txt</M>
<M ID="D">modelD.txt</M>
</MODELS>
</EVAL>
</ROUGE_EVAL>
Although your input format type might be different, I find that SPL works for .txt and SEE is for HTML.
One thing that tripped me up was: <M ID="A">modelA.txt</M>, I had it as <P ID="A">modelA.txt</P>, ROUGE didn't complain, it just came out with 0 for every value. So keep an eye out for small things like that.
In Sublime Text 2, I'd like to create a snippet for Rails image_tag.
I want it to be a trigger, but it seems that it is already taken by <input>.
I'd like to remove <input> snippet at all. I've looked through most of Sublime packages, but I cannot find it anywhere.
Is there an easy way to find or override the <input> snippet?
First, if you are dead set on using it to trigger the snippet, you will need to edit this file:
~/Library/Application Support/Sublime Text 2/Packages/HTML/HTML.tmLanguage
and remove input from the string
<key>begin</key>
<string>(</?)((?i:a|abbr|acronym|area|b|base|basefont|bdo|big|br|button|caption|cite|code|col|colgroup|del|dfn|em|font|head|html|i|img|input|ins|isindex|kbd|label|legend|li|link|map|meta|noscript|optgroup|option|param|q|s|samp|script|select|small|span|strike|strong|style|sub|sup|table|tbody|td|textarea|tfoot|th|thead|title|tr|tt|u|var)\b)</string>
Next, comment out this line
{ "trigger": "input", "contents": "<input>" },
from ~/Library/Application Support/Sublime Text 2/Packages/HTML/HTML.sublime-completions
input should now be free to use as you like in HTML scopes.
Go to Tools -> New Snippet... and the write the following:
<snippet>
<content><![CDATA[
<%= image_tag ${1}, ${2} %>
]]></content>
<tabTrigger>it</tabTrigger>
</snippet>
And finally save the snippet.
This snippet it's working perfectly for me.