I have problem to use html.erb files in vscode, I tried to format my document and i did it, but the document lose the style just like in the picture:
https://ibb.co/KLqjfcV
settings.json I have:
"files.associations": {
"*.html.erb": "html"
},
"emmet.includeLanguages": {
"html.erb": "html"
}
I appreciate any comments!
I think you need to install some package as well as set some settings up as mentioned in this post
Related
I have a problem with ionide-fsharp formatter. When I install the extension in VSCode I am not able to automaticaly format a file on save. I have fantomas installed globaly and I tried to go through FSAC, but nothing has helped. I think that I need to put something in VSCode's settings.json like I have a prettier config for typescript.
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
So this is how my own config looks like
"[fsharp]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "Ionide.Ionide-fsharp"
},
You should ensure that editor.formatOnSave is set to true (either for just the fsharp language or globally) and then FSAC should pick up your globally-installed Fantomas.
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.
I tried this editor, but received many errors, maybe existing some editor, which I can easy install and update images.
My answer:
Now I use this editor, very easy to install.
Im using tinymce with the gem 'tiny_mce' and carrierwave for image upload.
My setup for tinymce is following:
$(function() {
tinyMCE.init({
mode: "textareas",
editor_deselector: "plain",
theme: "advanced",
plugins: "advimage,inlinepopups,save,autosave",
external_image_list_url: '#{image_list_admin_static_images_url}',
relative_urls: false,
theme_advanced_buttons1: "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect",
theme_advanced_buttons22: "",
theme_advanced_buttons3: "",
theme_advanced_toolbar_location : "top",
theme_advanced_blockformats: "p,h2,h3,h4"
})
}
The important part is image_list_admin_static_images_url in my routes i have:
resources :static_images do
get :image_list, :on => :collection
end
Method in StaticImagesController looks like:
def image_list
#image_list = "var tinyMCEImageList = #{StaticImage.image_list.to_json}"
render :js => #image_list
end
And in image_list method located in the model:
def self.image_list
all.map{ |im| [im.alt, im.image.url] }
end
This setup works perfectly for me, ofc you need to customize it for your own needs. Hope this will help you. TinyMCE is really nice and powerfull wysiwyg editor.
As chech suggested in the comments section, here is how you can adjust this solution for use with active_admin:
To use it inside active admin simply replace the route for this one:
match "admin/model_name/:id/js_image_list", :action => "js_image_list", :controller => "admin/model_name". Then create an action called js_image_list inside the active admin model file. Configuration for tinyMCE.init is: external_image_list_url : "js_image_list"
It seems like tinymce is definitely supported by rails 3.1. Here is the link
http://rubygems.org/gems/tinymce-rails
All you have to do is add the following to your Gemfile
gem 'tinymce-rails'
You have the following options to add to application.js depending on whether you want to use jquery or not
//= require tinymce-jquery
//= require tinymce
Personally I chose jquery so I added this line to the js.coffee file corresponding to my controller/view
tinyMCE.init
mode: 'textareas',
theme: 'advanced'
If you don't want to use jquery you can just add this script to your view
<script type="text/javascript">
tinyMCE.init({
mode: 'textareas',
theme: 'advanced'
});
</script>
I had problems with tinymce and Rails asset pipeline. I have not, also, found a way to start tinymce with increased font size. The default font size is very small.
If you are using twitter bootstrap one fantastic option is:
https://github.com/jhollingworth/bootstrap-wysihtml5
If you want something that works with HTML5 I would go with:
http://jejacks0n.github.com/mercury/
Awesome!
When I paste a URL into a TinyMCE editor it converts the text into a link.
So http://vimeo.com/18150336 would be come http://vimeo.com/18150336. I would like to keep the plain text. Is their a way to configure TinyMCE to keep the link as plain text.
I do not want to strip out tags as adding a hyperlinks should be an option on the toolbar. It should just not happen by default.
You can use the paste plugin and the setting paste_preprocessing in order to keep the plain text. You might need to check inside the function specified using paste_preprocessing if you got a link or not.
It's been 5 years, So I'm probably using a newer version of TinyMCE, anyway this solution worked for me, Just add this option:
paste_preprocess: function(plugin, args) {
args.content += ' ';
}
So when you initialize the tinymce, it should be something like this:
tinymce.init({
selector: "textarea", // change this value according to your HTML
plugins: "paste",
paste_preprocess: function(plugin, args) {
args.content += ' ';
}
});
This is the page of documentation for TinyMCE V4
It is the TinyMCE plugin autolink which is responsible for automatically creating links on paste. (And write).
https://www.tiny.cloud/docs/plugins/opensource/autolink/
I'm using TinyMCE on my blog and it seems to be removing the code I'm trying to paste.
I want to add this:
<Files somefile.png>
DefaultType application/x-httpd-php
</Files>
(it's a .htaccess directive)
This gets saved ok (as < and > in the html), but when I reopen my form for editing, it gets transformed as :
DefaultType application/x-httpd-php
Edit : I'm using TinyMCE in a Symfony form, using sfFormExtraPlugin.
Edit 2 : I tried verify_html: false ....
now my code gets transformed as :
<p><files exec="" jpg=""><br /> DefaultType application/x-httpd-php<br /></files></p>
Edit 3: My tinyMCE config is :
tinyMCE.init({
mode: "exact",
elements: "content_contents",
theme: "advanced",
width: "500px",
height: "400px",
theme_advanced_toolbar_location: "top",
theme_advanced_toolbar_align: "left",
theme_advanced_statusbar_location: "bottom",
theme_advanced_resizing: true
,
language : "fr",
convert_urls : false,
verify_html : false
});
I responded to this on the TinyMCE MoxieCode forums topic that was also opened by #Manu however I wanted to update this topic with my thoughts as well.
If I understand #Manu correctly, the problem is that the HTML source, while saving with < and > correctly is being interpreted as < and > when reloaded into TinyMCE.
If this is the case, then I believe the problem is that the Symphony plugin isn't encoding the HTML content prior to populating the TextArea that TinyMCE replaces. In other words, it leaves < when it should be loading &lt; so tinyMCE receives <
What are you doing to the input when putting it back in to TinyMCE? If you're converting it to HTML or anything TinyMCE will clean it up as it's invalid HTML.
As a work around/experiment you could add File in the custom_elements option in your init.
Update As you are accepting all sorts of code, you will probably have to turn off clean up altogether. Put cleanup: false in the config. If I were you I would implement your own custom formatting (like Stack/overflow does) and generate bold, underline, links etc formatting because it will give you a lot more control over the HTML generation, ie you could just print out everything exactly how it is (with escaping), and then turn the pre-defined symbols to <strong> tags, or what ever. This is be far the easiest way of generating safe, accurate HTML output, and in your case, probably the only way.
You would not want to use TinyMCE is this case...
That is because the invalid HTML gets removed (the tinymce cleanup functionality).
A workaround could be to initialize tinymce using the cleanup paramter:
cleanup: false,
I suggest you have a closer look at the tinymce initialization parameters
custom_elements
valid_elements
and
cleanup
replace your < and >
< becomes: <
> becomes: >
Try including
extended_valid_elements : "Files[]",
In your config. It's used to unlock certain html tags like iframe. In the brackets you usually put the allowed options for the tag (like [src|alt|id]) so I'm not sure what to put there for your example ...
the correct answer to your problem, tested by me and 100% working is to wrap your variable into htmlspecialchars in php like this example:
htmlspecialchars($myText)