question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deprecated HTML tags such as <font> are used in Summernote

See original GitHub issue

Tags such as <font> were deprecated many moons ago and are not supported in HTML5. I believe Summernote’s success depends on it producing the cleanest, minimalist and best practise HTML known to mankind.

steps to reproduce

  1. Write some text
  2. Use the font colour tool to change the text colour
  3. View the HTML and see the <font color="#00ff00">example</font> in all its glory

image

In this I would suggest <span style="color: #0f0">example</span> should be used. I see that in other places Summernote does use inline styles like this so I think this should be consistent across the font colour styles too.

Whether or not <font> works, this is a question of style and making Summernote not appear like one of the old-school text editors.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:18 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
renetanikolovacommented, Mar 26, 2019

I don’t know if someone needs an alternative, but I found one:

Using sanitizer works perfectly for me: https://www.npmjs.com/package/sanitize-html-react

And specifically for the font tag: there is an option to replace it:

here is a simple example (I am using React):

import sanitizeHtml from 'sanitize-html-react';

let dirty = '<p>a nesty example &nbsp; &nbsp;</p><p><br></p><p><br></p><p><font face="Gilroy Light">Gilroy Light</font></p><p><font face="Gilroy Light"><br></font></p>';
        
let clean = sanitizeHtml(dirty); // some basic cleaning

clean = sanitizeHtml(dirty, {
    allowedTags: false,
    allowedAttributes: false,
    transformTags: {
        'font': function (tagName, attribs) {
                return {
                    tagName: 'span',
                    attribs: {
                        style: "font-family:'" + attribs.face + "';"
                    }
                };
        }
    }
});

Setting flags: allowedTags: false, allowedAttributes: false allows all tags and attributes. If you need to allow only a specific set of tags and attributes, there are examples in the documentation.

I hope that would help some of you!

Best wishes, Reneta

1reaction
DiemenDesigncommented, Dec 5, 2020

This has been added to the Projects List, you can check the progress here https://github.com/summernote/summernote/projects/2

Read more comments on GitHub >

github_iconTop Results From Across the Web

Deprecated HTML Tags - W3docs
Deprecated HTML Tag List ; <big>, Increases the font size by one conventional unit. CSS styles ; <blink>, Creates an enclosed text, which...
Read more >
Deep dive - Summernote
Summernote automatically populates the font dropdown with the available fonts that are given on fontNames option. This includes the font set on the...
Read more >
jQuery Summernote - Get text back into editor - Stack Overflow
Since v0.7.0 code() has been deprecated and removed (same story for destroy() method). You must use $(".summernote").summernote("code", "your text");.
Read more >
HTML5 - Deprecated Tags & Attributes - Tutorialspoint
Deprecated Attributes​​ Some attributes from HTML4 are no longer allowed in HTML5 at all and they have been removed completely. img and iframe....
Read more >
JavaScript · Bootstrap
Only one plugin per element via data attributes. Don't use data attributes from multiple plugins on the same element. For example, a button...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found