jcberquist / commandbox-cfformat

A CommandBox module for formatting CFML component files.
MIT License
22 stars 10 forks source link

Ignores not working on this method #93

Open lmajano opened 3 years ago

lmajano commented 3 years ago

Ignores not working on this method for some reason:

function processStackTrace( required str ){
        // cfformat-ignore-start

        // Not using encodeForHTML() as it is too destructive and ruins whitespace chars and other stuff
        arguments.str = HTMLEditFormat( arguments.str );
        // process functions e.g. $funcINDEX.runFunction(
        arguments.str = reReplaceNoCase( arguments.str, "\$([^(\(|\:)]+)(\:|\()", "<span class='method'>$\1</span>(", "ALL" );
        // process characters within parentheses e.g. (ServletAuthenticationCallHandler.java:57)
        arguments.str = reReplaceNoCase( arguments.str, "\(([^\)]+)\)", "<span class='highlight'>(\1)</span>", "ALL" );
        // process characters in brackets e.g. [hello world]
        arguments.str = reReplaceNoCase( arguments.str, "\[([^\]]+)\]", "<span class='highlight'>[\1]</span>", "ALL" );
        arguments.str = replace( arguments.str, chr( 13 ) & chr( 10 ), chr( 13 ) , 'all' );
        arguments.str = replace( arguments.str, chr( 10 ), chr( 13 ) , 'all' );
        arguments.str = replace( arguments.str, chr( 13 ), '<br>' , 'all' );
        arguments.str = replaceNoCase( arguments.str, chr(9), repeatString( "&nbsp;", 4 ), "all" );

        // cfformat-ignore-end

        return arguments.str;
    }

It still manages to manipulate to this:

function processStackTrace( required str ){
        // cfformat-ignore-start

        // Not using encodeForHTML() as it is too destructive and ruins whitespace chars and other stuff
        arguments.str = HTMLEditFormat( arguments.str );
        // process functions e.g. $funcINDEX.runFunction(
        arguments.str = reReplaceNoCase( arguments.str, "\$([^(\(|\:)]+)(\:|\()", "<span class='method'>$\1</span>
(", "ALL" );
        // process characters within parentheses e.g. (ServletAuthenticationCallHandler.java:57)
        arguments.str = reReplaceNoCase( arguments.str, "\(([^\)]+)\)", "<span class='highlight'>(\1)</span>
", "ALL" );
        // process characters in brackets e.g. [hello world]
        arguments.str = reReplaceNoCase( arguments.str, "\[([^\]]+)\]", "<span class='highlight'>[\1]</span>
", "ALL" );
        arguments.str = replace( arguments.str, chr( 13 ) & chr( 10 ), chr( 13 ) , 'all' );
        arguments.str = replace( arguments.str, chr( 10 ), chr( 13 ) , 'all' );
        arguments.str = replace( arguments.str, chr( 13 ), '<br>' , 'all' );
        arguments.str = replaceNoCase( arguments.str, chr(9), repeatString( "&nbsp;", 4 ), "all" );

        // cfformat-ignore-end

        return arguments.str;
    }
jcberquist commented 3 years ago

That is odd, in my testing I can't reproduce this. I went and found the original file in the ColdBox repo and used the .cfformat.json file there and tried formatting it, and it didn't produce any extra line breaks.

lmajano commented 3 years ago

So weird. Would it matter that the formatting runs via the watch command?

Luis Majano CEO Ortus Solutions, Corp 1-888-557-8057 909-248-3408 www.ortussolutions.com Support Open Source: www.patreon.com/ortussolutions Linked In: https://www.linkedin.com/pub/3/731/483 Social: twitter.com/ortussolutions | twitter.com/lmajano On Nov 20, 2020, 12:39 PM -0600, John Berquist notifications@github.com, wrote:

That is odd, in my testing I can't reproduce this. I went and found the original file in the ColdBox repo and used the .cfformat.json file there and tried formatting it, and it didn't produce any extra line breaks. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

jcberquist commented 3 years ago

@lmajano I think I finally might know what is going on here. I was just talking with @bdw429s about how cfformat handles UTF-8 files with a BOM, and I realized that cfformat, while preserving the BOM correctly, was not parsing such files correctly. I cloned the ColdBox repo and checked, and the source file in question has a BOM. This is hopefully fixed now in the latest version of cfformat (v0.15.14).