atom / one-dark-syntax

Atom One dark syntax theme
MIT License
448 stars 236 forks source link

PHP syntax highlighting issue inside HTML quotes #95

Closed chaance closed 6 years ago

chaance commented 7 years ago

Originally posted on the Atom discussion boards here.

Some PHP elements embedded into HTML strings are not formatted as PHP, rather they get the default HTML string formatting. I used the following code to address the issue in styles.less, but it's certainly possible that this could affect other code that I haven't encountered yet. If someone wants to use this as a starting point and submit a pull request, have at it!

    // Fixes php inside of strings
    .syntax--string .syntax--source,
    .syntax--string .syntax--meta.syntax--embedded.syntax--line {
      color: hsl( 220, 14%, 71% );
    }

    // The above fix affects punctuation in the closing php tag,
    // so use this to reset the color accordingly.
    .syntax--string .syntax--punctuation.syntax--section.syntax--embedded .syntax--source {
      color: hsl( 5, 48%, 51% );
    }
simurai commented 6 years ago

This seems to be fixed.

<?php
  echo esc_url( get_term_link( $term ) );
?>
<a href="<?php echo esc_url( get_term_link( $term ) ); ?>" class="site__nav_link">

Renders as:

image