area / language-latex

Syntax highlighting for LaTeX for Atom.
Other
79 stars 47 forks source link

Package should ignore after hyphenation #205

Open JackSwett opened 5 years ago

JackSwett commented 5 years ago

Prerequisites

Description

Text inside the brackets after the \hyphenationcommand are processed as normal text and therefore get spell-checked.

Steps to reproduce & Minimum working example

  1. Put \hyphenation{op-tical net-works semi-conduc-tor} near the top of your file.
  2. Spell check with linter-spell and linter-spell-latex

Expected behaviour

tical and conduc are marked as mispelled.

Actual behaviour

tical and conduc are marked as mispelled.

Additional information

I have solved the issue by adding the following to grammars/latex.cson.

EDIT: This seems to work the first time I relaunch Atom, then it doesn't work after....

  {
    'captures':
      '1':
        'name': 'support.function.be.latex'
      '2':
        'name': 'punctuation.definition.function.latex'
      '3':
        'name': 'support.function.general.tex'
    'comment': 'This matches the hyphenation command to force proper hyphenation'
    'match': '(?:\\s*)((\\\\)hyphenation)({(.{1,1000})})'
    'name': 'meta.function.hyphenation.latex'
  }

This should be added to the code, but I'm not very good at RegEx, so I wanted to post here. There is probably a better way than what I did. Obviously if you have over 1000 characters to correct hyphenation on, you should probably use shorter words as this fix won't work. Is there a better RegEx to use? (the 1,1000 seems clunky)