Cannot get htmlproofer to ignore missing image alt tags - html

I'm running htmlproofer to check a WIP Jekyll-generated site that currently has a lot of missing image tags. I'd like to ignore the for the time being until other broken links are resolved. I expected this pattern would work:
bundle exec htmlproofer ./_site --assume-extension --empty-alt-ignore --disable-external
However it still returns errors for missing alt tags. What am I doing wrong?

Passing --alt-ignore '/.*/' instead of --empty-alt-ignore should help you.
--empty-alt-ignore is for ignoring alt tags set to ""

Related

Ckeditor 4 is removing the <img> tag if the HTML is not correct. How to stop this behaviour

we are using CKEditor in our project. We recently upgraded the version from 3.X to 4.x. After the update, we are not able to see <img> tags in the old saved documents. When we click on the source, we see
<p> <p> in place of a <p><img ......><p>.
On further debugging, we found that many documents which had the <img> tag were also having a junk attribute in the <img> tag like <img /="/" src="/folder/11801321/112267100.neck.png" height="308" width="467">.
By junk, I mean this part of tag /="/". This was a bug introduced while we were processing the user's input. We reverted old CKEditor version to 3.X and the editor was internally taking care of the junk values. it was trimming it off. so the users never complained.
But now the CKEditor 4 is not handling the HTML in the same way. It is actually stripping the whole <img> tag.
We have two options to fix this issue.
1. Remove the junk characters in all the documents. This is huge data. Needs approval from the user to do it.
2. Change CKEditor 4 config settings to get the same behavior as the CKEditor 3.X.
We are in favor of point 2. I have been searching and trying couple of config settings but haven't been able to nail it.
Let me know if any one has faced the same issue and have resolved it.
If you really want you can set all the code inside the img tag as "protected" and this way the editor will not strip this code:
CKEDITOR.config.protectedSource.push(/<img \/="\/" .*?>/g)
Remember that your final html will not be valid.
Since that part of the code is "protected" you will not see these images in the editor.
Here is a working example for that:
https://jsfiddle.net/oLb4Lmdb/
However - I really think it will be best to replace the string <img \/="\/" with <img in the source once the ckeditor instance is ready:
CKEDITOR.instances.editor1.on('instanceReady', function() {
this.setData(this.getData().replace("<img /=\"/\"", "<img"))
})
This way you don't need to go over all the data in the "backround", and the replacement will be done "on the fly" for every document that you need to edit.
You can check this jsfiddle:
https://jsfiddle.net/k1ewc29p/

MariaDB: Remove Specific Link From Column

I recently detected on my cousin's blog a few click-jack links. I was alarmed because I immediately said to myself that I had some crappy adware on my browser... However I didn't. The links on the picture didn't even work.
On her computer and the links were working. I opened Chrome Extensions and there was some suspicious stuff there. After removing everything the links stopped working too.
I went to the database and saw this:
So apparently the Wordpress installation was not compromised and it was just the Chrome Extensions adding extra HTML to the post.
My Question: Is there a way in SQL I can remove all those links?
The ideia is to find the word DiscountMan and look for an anchor tag before that and the closing after and remove the tag, but leave the word on the middle intact.
<a class="garehbqm" title="Click to Continue > by DiscountMan" href="#10518549"> lifestyle<img src="http://cdncache-a.akamaihd.net/items/it/img/arrow-10x10.png" alt=""></a>
The link and the image tag should be removed, however anything else inside the tag, like lifestyle (space before) should be kept.
Note: I can remove the img tag with this:
UPDATE table SET fieldname=REPLACE(fieldname,'<img src="http://cdncache-a.akamaihd.net/items/it/img/arrow-10x10.png" alt="">','');
But I don't know how to solve the link issue.
Thank you.
Can you Switch to MariaDB instead of MySQL? It has a REGEXP_REPLACE build-in. With it you can do a
SELECT REGEXP_REPLACE(fieldname, "(<a .* title=\\".*DiscountMan\\"[^>]*>)([^<]*)(<img [^>]*><\/a>)", '\\2')
See this post.
You can test it on enter link description here

Regex match and delete everything before string (opening html tag)

I'm using Dreamweaver and Notepad++ and have searched high and low but nothing seems to work from what I've found.
I've got a whole stack of html pages and I need to remove from all of them everything above but not including the first tag in the document. Specifically, everything before the string "<h1" (no quotes). I've tried various examples in Notepad++ and it finds the first h1 tag but doesn't replace everthing before it.
Assuming you want to lose everything in your file before the "<h1" text
then specify ".*<[hH]1" as search tag and "<h1" as replacement and check
the box marked ". matches newline". Works for me.
You can do this from the Command Line or a text editor that allows you to search-replace multiple files. However, are you sure the content is the same in every html file?

Syntax in Sublime Text 2 Converts From "HTML" to "HTML (RAILS)" on save

I've tried various fixes with this, and it is really annoying me now.
Whenever I open a file as html, the default syntax for the file changes to HTML (RAILS). I can flip it back to HTML by the little select list in the corner, but it reverts. I've tried changing syntax specific files, setting extensions, etc. I even grepped HTML (RAILS) in my Sublime root folder recursively, and found nothing.
The thing that makes it hard to pin down, is that there is no extension difference. No matter which syntax highlighting I choose, the tag is the same.
I don't need syntax highlighting or autocomplete for HTML, but I do really like how matching tags are underlined in HTML syntax highlighting, and without it, I often miss unmatched tags, and cause lots of extra work for myself.
Any guesses on what this is / how to restore HTML to proper clean HTML highlighting?
(Note: The behaviour is identical for HTML and HTML5 and as I discussed in this post, I can't get tag matching to work in HTML5 anyway. That problem preceeded this one, but using HTML instead of HTML5 was an acceptable fix - that no longer works.)
In case anyone else has this bizarre issue, I've solved it.
There is a package installed (dont' remember if it was installed from the beginning, or if I added it) called Syntax Matcher. I commented out the following lines in a file called SyntaxHighlighter.py:
if self.ext == '.html':
self.set_syntax('HTML (Rails)', 'Rails')
return True
And the problem was solved instantly.

ParseError: Unexpected end tag - How to clean html tags?

I'm starting to learn web development and am using pyramid with chameleon. I just took some sites html source as a template in Dreamweaver and then copied the code into a chameleon .pt file.
The html code displays fine in dreamweaver but I get this error when running it in pyramid:
chameleon.exc.ParseError
ParseError: Unexpected end tag.
- String: "</div>"
I have tried dreamweavers cleanup function and it said it removed 2 empty tags but I still get this error. My traceback is all related to errors in the chameleon and doesn't show the specific line its having problems with in my template itself.
Is there a way to identify the actual line where the error is occurring?
I'm not sure if there's a pyramid or chameleon specific solution or if there are general methods to find errors in HTML tag.
Chameleon expects templates to be well-formed, and is less forgiving of unbalanced tags and incorrect attribute markup as DreamWeaver is.
Note that the error doesn't necessarily mean that there is a </div> tag too many. If the opening <div> has a syntax error such as a missing = on an attribute declaration (e.g. <div class"foobar"> then the opening tag is not recognized and the corresponding closing tag is going to be flagged as well.
You could run your template through an XML validator, there are several available online (such as http://www.validome.org/xml/, http://www.xmlvalidation.com/ and http://xmlgrid.net/, Google lists many more). These are bound to give you a slightly more helpful message as to what is wrong with your template.
Never used pyramid/chameleon before, but it looks like you have to go through the code and remove an extra </div> tag. When you get the message that it removed two empty tags, that probably means it removed the open and closing of a set of tags
e.g. <div></div> or <p></p>
Go through your code and for every <div> there should be a </div>.