I'm running D7 and Panopoly and the HTML editor is stripping out css classes that begin with hyphen (ex: class="cta -btn" produces class="cta").

Repeatable: Always
Steps to repeat:
1. Edit a node with a body field using the HTML editor
2. Add HTML with a class with a hyphen class name
3. Save changes
4. View source HTML of outputted page

Expected Results:

<a href="#" class="cta -btn">
  <span class="wrap">
    <span class="content">See Where This Takes You</span>
  </span>
</a>

Actual Results:

<a href="#" class="cta">
  <span class="wrap">
    <span class="content">See Where This Takes You</span>
  </span>
</a>

I’ve found that allowed class names are filtered in the Rules for Class Names section of /admin/config/content/formats/panopoly_html_text but when I add -*, it says it’s an invalid expression. However, W3C says a single hyphen is allowed at the beginning of a class.

Comments

dsnopek’s picture

Project: Panopoly » WYSIWYG Filter
Version: 7.x-1.14 » 7.x-1.6-rc2
Component: WYSIWYG » Code
Category: Feature request » Bug report
Issue tags: -CSS, -wysiwyg +panopoly

That filtering is provided by the wysiwyg_filter module:

https://www.drupal.org/project/wysiwyg_filter

I'm moving this issue over there.

geek-merlin’s picture

Project: WYSIWYG Filter » Panopoly
Version: 7.x-1.6-rc2 » 7.x-1.x-dev
Component: Code » Miscellaneous

If this still applies (which i doubt), the issue must lie in the class name regexp which is configurable.

geek-merlin’s picture

Component: Miscellaneous » WYSIWYG
cboyden’s picture

Project: Panopoly » WYSIWYG Filter
Component: WYSIWYG » Code

According to the help text for WYSIWYG Filter's allowed class names field:

Class Names should start with an upper or lower case letter "a to z"

If you enter a class name that starts with a hyphen, you get an error message like this:

Invalid expression -test. Please, check the syntax of the Rules for Class Names field.

This error isn't coming from Panopoly, it's in the validation provided by wysiwyg_filter.

  • axel.rutz committed cd1e1d0 on 7.x-1.x
    Issue #2394403: HTML text filter strips classes starting with hyphen
    
geek-merlin’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.