Possible bug in Blade templating system with html special characters - templates

I'm not necessarily sure about this but it seems there's something strange going on with umlauts, accented characters and such on Blade templates with Laravel 5.1.
I was banging my head on the wall with a string that ended in an ä-letter which I really, really couldn't get decoded with html_entity_decode no matter what I tried.
Here's what I had in my Blade template file as I was going mad:
{{ html_entity_decode('just-another-string-ä') }}
Now, when I render the template in a browser window I obviously get:
just-another-string-ä
But in the source I have the following:
just-another-string-äauml;
Which in my understanding does not stand for the string that I had given in the blade template.
...several minutes pass by...
After a while I changed the string to:
just-another-string-ä-test
And as a source-code result I get:
just-another-string-ä-test
Which indeed is much easily decoded than the "almost-double-auml" I got with the first string. In addition to the final letter/word replace I also noticed that things work as expected when I enter a line break in the Blade template after the line.
{{ html_entity_decode('just-another-string-ä') }}
{{-- erase this comment --}}
And everything is in order in the source code:
just-another-string-ä
Have I completely missed something here or does this smell like a bug?

Okay I've found the problem, though not really much of a solution.
After looking into this I found that it's not a Blade issue. Neither is it PHP or Apache - it's your browser.
For example, just create yourself an HTML file with the following contents:
this-is-a-string-ä
For me (at least in Chrome, I haven't tested other browsers), this will produce the same issues as you are seeing. If you have no trailing newline, view source will break, but if you do have one, it's fine.
So the solution is simple, enable the "blank newline at end of file" setting in your text editor. You should really have this turned on anyway, for example diffs work a touch better with a blank line at the end of a file (they don't see a difference where there is none), which means, by extension, version control systems like Git handle them a bit better. And it doesn't really hurt to have this enabled that I've ever found.
I would imagine that this is almost certainly a known issue, but I haven't looked into Chrome issue tracker or anything. Feel free to do so though, if you do want to get to the bottom of it. I'd be interested to know :)

Related

Adding preamble.tex and/or modifying css

Thanks for making papaja. It's really terrific!
I just submitted my first journal article using it and ran into problems. The layout staff don't know what to do with the code chunks and listings that are fine in single-column, full page format, but not in their 2-column format. I'm trying use the class 'jou' option to make 2 columns, but I can't figure out how to control the size of code and listing fonts (possibly by modifying the css, as recommended here), or how to using the latex package 'listings' to set listings to wrap (as recommended here).
I'd be grateful for any advice, and my apologies if I've missed how one might do this in the documentation.
If it's only about getting the listings package to work, you can modify the YAML header that it looks similar to the following:
documentclass : "apa6"
classoption : "jou"
output :
papaja::apa6_pdf:
pandoc_args: --listings
header-includes:
- \lstset{breaklines=true}
However, note that using automatic line breaks will most likely break the code at some points. Therefore, it is worthwhile to consider alternatives: For instance, you could try to use a code style that uses more line breaks. The styler package and add-in might be helpful accomplishing this: https://styler.r-lib.org/

WebStorm erroring for what appears to be no reason

I am not sure what is going on here. I have a brand new template that someone wrote and I plug it into my editor and get these lovely red squiggly lines. I cannot see any syntax errors so I'm thinking its the editor.
The first thing I see is on the import statement. Why is there a red squiggly there? It is telling me statement expected but that is a simple import statement!
There is yet another after the const serializers. I will likely miss an actual error if these stay on here. I have tried changing the language and it is telling me that it knows its a Vue Component via the V symbol on the file in the Project tab.
I'm not sure what to do here.
Wow, I took a break and came back. Tried to load the component in Vue and it fails with the error.
unexpected character ' '
So it was a damn space! There were a few spaces, maybe it came from the fact that I copied the code?
I'd suggest trying the Zero Width Characters locator plugin - it helps to visualize hidden control characters that might break the syntax highlighting and code execution

Add line-break to open graph meta tag [duplicate]

This is an URL I have to send an invitation to an app of mine:
https://www.facebook.com/dialog/send?app_id=MY_APP_ID&
name=hola&
link=http://www.aWebSite.com&
picture=http://www.aWebSite.com/im01068442.jpg&description=participar!&
redirect_uri=http://elsuperdt.com
I'm trying to have a linebreak included within the description, but I just haven't found a way to do so. How do I do it?
I had the same issue and eventually gave up. Facebook seems to have gone to great lengths to avoid letting us have any linebreaks in the description.
The one thing you can do is add a &caption=first%20line which gets you one linebreak between the caption and the description. (There's a pretty short limit on how long the caption can be though - something like 80 characters.)
Update: this no longer works for send dialogs. It does still work for feed dialogs
Try using <center></center> this will create a new line in Facebook dialog description.
Try including %0D%0A in your description where you want the line break to be. This is the URL-encoded equivalent of a line break.
\n works in message but not in name parameter
I tried center></center> and %0D%0A. Both worked... for a split second. You could see the breaks upon page load, and then, like evil magic, facebook took it away and it was all scrunched up. Too bad. I'm trying to share a daily schedule, which would look much better with line breaks.
You can use blanks that are not posted to facebook in the length of the feed so the line breaks.
Or you just style your post by adding ".........." in the end of each line. This way people would maybe be more attracted to your post as they are eyecatching.

Regex with iframe in Yahoo! Pipes

I'm building a Yahoo! Pipe to pull an RSS feed from Reddit which links to some content in the description. I'm using a regex to match the href attribute of the anchor link in an item.description field. The regex I'm using is:
^.+?href="([^"]+)">\[link\].+?$
As a test, I set the replace to simply:
$1
and I see that the entire description field has been replaced with the URL. So far, so good.
I then put the following in the replace field. The idea being to iframe the content that's linked to:
Content: <iframe src="$1">no iframe support</iframe> End
What I get out however is:
Content: no iframe support End
I've confirmed that this is also coming through in the pipe's output and not just in the Yahoo! Pipes debug console.
I've so far tried replacing my angle brackets with < and > entities. I've tried wrapping the entire thing in a <![CDATA[ ... ]]> block and still, I get nothing. If I break my iframe tag by removing an angle bracket, the broken content comes through fine, but if I have a well-formed iframe element, it vanishes, leaving the "no iframe support" text. Am I doing something wrong here, or is Yahoo! actively preventing me from using iframe tags in my generated pipe? A cursory search on Google isn't turning up anything related to this.
The pipe in question is here:
http://pipes.yahoo.com/pipes/pipe.info?_id=2ba41448cadd2347d86f377efd3d199f
This Pipes FAQ Question "Why does Pipes Strip <object> and <embed> tags... ?" shows that a certain amount of sanitization is performed, by placing content (at least certain content) into an iframe for the safety of RSS consumers - though it does not state it specifically, this probably also removes other iframes in order to avoid nesting and other work-arounds.
Yahoo is big enough I would doubt they have a week sanitizer, but an extremely long shot is that you might be able to fool it by nesting the iframe in a bunch of other tags (again I doubt this will work). Also depending upon which step does the sanitization, perhaps adding part of the tag in one step, then adding another part somewhere else might work (yet again, doubt overwhelms me)
Not sure what else to suggest, other than getting something else to consume and transform your RSS a little bit more (by fixing otherwise broken tags??) - but that's what you're using pipes for to begin with, isn't it? Idunno...
Good luck!
Pipes has an fanatical devotion to the RSS spec and the spec says the description field is plain text only. HTML etc is supposed to go in the content:encoded field, not that I've had much luck getting pipes to do that.

CFEclipse doesn't recognize structName in cfimage tag

This code:
<cfimage action="info" structName="imageInfo" source="#imagePath#">
is giving this error:
The attribute 'structName' is required for the tag. (Found:
[source, structname, action])
When I run this code in CFBuilder - everything is OK, but I must use CFEclipse.
What should I do (I use CF9)?
Thank you for your answers!
Of course this problem won't prevent you from running your application on ColdFusion. It is just an IDE warning that something is wrong.
You have a few options.
Try using a lowercase N in structName. i.e. structname. ColdFusion is not case-sensitive, but Java is, and CFEclipse is a Java application.
If that does not work, then it probably means that the dictionary file that drives the code assist is not correct. You can go earch forthose XML files and update them to include that attribute.
You can use CFBuilder. I know you said you can't, but I have to question why. You know there is a free version that is just as good as CFEclipse, right?
The problem is that there's a casing glitch in that file Peter mentions. There's one reference to "structName" to define the attribute itself, and another "structname" which is in the list defining which attributes are needed for action="info". If you make them both the same, then restart Eclipse, you should be OK (that's I've needed to do to make the error indicator go away).