To avoid the problem caused by a css file edited on a Mac (5 posts)

  1. delarge
    Posted 9 years ago #

    I'm sure this has been reported here a number of times, but if you edit the css file of a theme on a Mac, it screws the thing up because the default line ending of Macintosh(\r) is different from Unix's(\n) and Windows'(\r\n).

    It is caused by the file() function used inside the get_theme_data() function (/wp-includes/function.php). The file() function by default does not recognize the mac line endings.

    So I suggest you define the function below somewhere and use it instead of the default file():

    function file_wp($filename) {

    $f = fopen($filename, "rb");
    $buffer = fread($f, filesize($filename));
    $lines_array = preg_split("/\r?\n|\r/", $buffer);
    return $lines_array;


    Hope the problem will be gone this way, or any other way for that matter, with a future update.

  2. moshu
    Posted 9 years ago #

    An even simpler (=without messing with code) solution is to have a text editor where you can define the line endings. That's what has been suggested in numerous cases.

  3. delarge
    Posted 9 years ago #

    Yes, I also think that's the simplest way for normal users right now, but I just hope the developers will address the problem with a future update because that's still too much hassle for Mac users. I believe wordpress should support as large a number of people as possible by default without forcing some people to do something extra, and the solution is pretty simple on this issue at least on the developers' side.

  4. pumilamac
    Posted 9 years ago #

    There are freeware text editors for the Mac that lets you choose line breaks, my favorite is TextWrangler.

  5. ruzel
    Posted 9 years ago #

    I was just having this problem. If you are using BBedit or Texwrangler you can change the line endings to Unix Style in the menu bar of the document (the drop down menu that looks like a doc will have "mac" and "unix"--switch to Unix)

Topic Closed

This topic has been closed to new replies.

About this Topic