       }
       {
         comment: 'Forces out of mathmode. Actually implemented in the mathMode patterns, as I dont know how to force an exit indirectly.'
-        match: '% !(?>T[eE]X) syntax = text'
+        match: '% !(?>T[eE]X) syntax\\s*=\\s*text\\s*$'
         captures: 0: name: 'keyword.control.magic.syntax.text.latex'
       }
       {
-        begin: '% !(?>T[eE]X) syntax = verbatim'
+        begin: '% !(?>T[eE]X) syntax\\s*=\\s*verbatim\\s*$'
         beginCaptures: 0: name: 'keyword.control.magic.syntax.verbatim.latex'
         end: '(?=% !T[eE]X syntax)'
         contentName: 'markup.raw.verbatim.latex'
       }
       {
-        begin: '% !(?>T[eE]X) syntax = none'
+        begin: '% !(?>T[eE]X) syntax\\s*=\\s*none\\s*$'
         beginCaptures: 0: name: 'keyword.control.magic.syntax.verbatim.latex'
         end: '(?=% !T[eE]X syntax)'
         contentName: 'meta.syntax.none.latex'

      }
      {
        comment: 'Forces mathmode until the next magic syntax comment'
        begin: '% !(?>T[eE]X) syntax = math'
        beginCaptures: 0: name: 'keyword.control.magic.syntax.math.latex'
        end: '(?=% !T[eE]X syntax)'
        contentName: 'string.other.math.latex'

    patterns: [
      {
        comment: 'Simplify syntax highlighting until the next magic syntax comment'
        begin: '% !(?>T[eE]X) syntax\\s*=\\s*plain\\s*$'
        beginCaptures: 0: name: 'keyword.control.magic.syntax.plain.latex'
        end: '(?=% !T[eE]X syntax)'
        contentName: 'meta.syntax.plain.latex'
