Skip to content

BugFix for unescaped html in shortcodes gets parsed/styled in visual editor #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions styles/syntaxhighlighter-editor-style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* SyntaxHighlighter Evolved
*
* A <pre> specific reset for the WordPress tinymce visual editor
* Syntax Hightlighter Evolved passes unescaped output
* to the tiny mce editor within <pre> wrapped shortcodes.
*
* This protects the shortcode content in this instance
* from being styled by user-agent styles
* and/or the theme's editor styles.
*
*/

pre *
{
background:inherit;
color: inherit;
font: inherit;
line-height: inherit;
margin:0;
padding:0;
}
9 changes: 9 additions & 0 deletions syntaxhighlighter.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ function __construct() {
add_filter( 'tiny_mce_version', array( $this, 'break_tinymce_cache' ) );
add_filter( 'save_post', array( $this, 'mark_as_encoded' ), 10, 2 );
add_filter( 'plugin_action_links', array( $this, 'settings_link' ), 10, 2 );
add_filter( 'mce_css', array( $this, 'editor_style' ) );

// Register widget hooks
// Requires change added in WordPress 2.9
Expand Down Expand Up @@ -305,6 +306,14 @@ function settings_link( $links, $file ) {
return $links;
}

function editor_style( $mce_css ) {
if ( ! empty( $mce_css ) )
$mce_css .= ',';

$mce_css .= plugins_url( 'syntaxhighlighter/styles/syntaxhighlighter-editor-style.css' );

return $mce_css;
}

// Output list of shortcode tags for the TinyMCE plugin
function output_shortcodes_for_tinymce() {
Expand Down