WordPress.org

Ready to get started?Download WordPress

Forums

Better WordPress Syntax Highlighter
[resolved] Support For Windows Live Writer (6 posts)

  1. umchal
    Member
    Posted 1 year ago #

    Hi,

    This is a very nice plugin.

    I usually post from Windows Live Writer, which is one of the best remote blog editor. And it automatically encode HTML formats in an editing post to escaped characters.

    If I write something like

    <?php
    $code= <<<STR
    <pre>hello</pre>
    STR; ?>

    Windows Live Writer converts it to
    <p>& lt;?php<br>$code= & lt;& lt;& lt;STR<br>& lt;pre& gt;hello</pre& gt;<br>STR; ?& gt;</p>
    in the source. (I inserted a space in the escape characters to display them in this post)

    Then, the plugin does not recognize it as a formatted language to highlight the syntax.

    I'm hoping that the plugin supports an option to allow such encoded code. The syntax for the option could be <pre lang="php" escape="true"> or something.

    By observing the Windows Live Writer's behaviour, it inserts <p> and <br> tags and escapes characters. So maybe if the option is set by the user, the plugin first strips tags and decodes the html format.

    Would it be possible?

    http://wordpress.org/extend/plugins/better-wordpress-syntax-based-on-geshi/

  2. Khang Minh
    Member
    Plugin Author

    Posted 1 year ago #

    Hi there,

    Yeah it is totally possible, the plugin actually supports that but there's no shortcode attribute for you to use at the moment. Will take care of this for the new version.

  3. umchal
    Member
    Posted 1 year ago #

    Thanks!

  4. umchal
    Member
    Posted 1 year ago #

    Hi OddOneOut,

    Have you had any chance to look into it? I'm hoping this is implemented. If you need someone to test, let me know.

    Regards,

  5. umchal
    Member
    Posted 1 year ago #

    I found a solution by customizing class-bwp-syntax.php.

    Around the line number #531, change this code block

    extract(shortcode_atts(array(
    			'lang' 			=> $this->options['select_default_language'], // assume it is the default lang
    			'toggle'		=> $this->options['enable_toggle'], // set to 'yes' or 'no'
    			'start'			=> 1,
    			'extra'			=> '', // string - list of lines to be double highlighted - e.g. 1,3,5
    			'inline'		=> '', // set to 'yes'
    			'nested'		=> '', // set to 'yes'
    			'parse'			=> 'yes', // set to 'no'
    			'strict'		=> '' // set to 'yes'
    		), $atts));

    to

    extract(shortcode_atts(array(
    			'lang' 			=> $this->options['select_default_language'], // assume it is the default lang
    			'toggle'		=> $this->options['enable_toggle'], // set to 'yes' or 'no'
    			'start'			=> 1,
    			'extra'			=> '', // string - list of lines to be double highlighted - e.g. 1,3,5
    			'inline'		=> '', // set to 'yes'
    			'nested'		=> '', // set to 'yes'
    			'parse'			=> 'yes', // set to 'no'
    			'wlw'			=> '', // set to yes
    			'strict'		=> '' // set to 'yes'
    		), $atts));

    This adds a custom shortcode parameter "wlw"

    Insert the following code around the line #574.

    if ($atts['wlw'] != '') {
    			$content = strip_tags($content, "<br><br /><br/>");
    			$content = str_replace(array("<br>", "<br />", "<br/>"), PHP_EOL, $content);
    		}

    When posting an article, enclose the code with [code wlw=”yes” lang="php"] ...code...[/code] ("codes inside [code] shortcodes." in the Parse Options has to be enabled via the admin panel.)

  6. Khang Minh
    Member
    Plugin Author

    Posted 1 year ago #

    Actually we should not use wlw="yes" 'cause it's too specific. Something like escape="yes" or esc="yes" would be more appropriate (just as you have suggested at the beginning).

    Either way, your workaround would be fine for the time being :).

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic