Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LilyPond: slightly improve lexing #2283

Merged
merged 1 commit into from Nov 27, 2022
Merged

LilyPond: slightly improve lexing #2283

merged 1 commit into from Nov 27, 2022

Conversation

lemzwerg
Copy link
Contributor

@lemzwerg lemzwerg commented Nov 26, 2022

  • Handle -- and __ as Token.Punctuation only if preceded by whitespace:

    <whitespace> --  ==>  hyphen (in lyrics mode)
    <whitespace> __  ==>  extender line (in lyrics mode)
    --               ==>  tenuto, neutral attachment (in music mode)
    __               ==>  portato, down attachment (in music mode)
    
  • Handle - followed by a number as Token.Number only if preceded by whitespace. This is purely heuristic, derived from the coding style shown in the LilyPond manuals.

    <whitespace> -3  ==>  integer (e.g., as a function argument)
    -3               ==>  fingering instruction
    
  • Add forgotten \maxima note duration.

  • Some legibility improvements by using verbose mode for regular expressions.

  • Some comment additions and fixes.

pygments/lexers/lilypond.py Outdated Show resolved Hide resolved
Copy link
Contributor

@jeanas jeanas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also update the test.

* Handle `--` and `__` as `Token.Punctuation` only if preceded by
  whitespace:

  ```
  <whitespace> --  ==>  hyphen (in lyrics mode)
  <whitespace> __  ==>  extender line (in lyrics mode)
  --               ==>  tenuto, neutral attachment (in music mode)
  __               ==>  portato, down attachment (in music mode)
  ```

* Handle `-` followed by a number as `Token.Number` only if preceded by
  whitespace.  This is purely heuristic, derived from the coding style shown
  in the LilyPond manuals.

  ```
  <whitespace> -3  ==>  integer (e.g., as a function argument)
  -3               ==>  fingering instruction
  ```

* Add forgotten `\maxima` note duration.

* Some legibility improvements by using verbose mode for regular
  expressions.

* Some comment additions and fixes.

* Update tests.
@jeanas
Copy link
Contributor

jeanas commented Nov 27, 2022

LGTM now.

@lemzwerg
Copy link
Contributor Author

Thanks!

hahnjo pushed a commit to lilypond/lilypond that referenced this pull request Dec 1, 2022
A [forthcoming change in Pygments]
(pygments/pygments#2283) improves rendering of `--`,
if representing an attached tenuto, as bold using LilyPond's `@tb` macro
instead of `@t`.

Previously, the `@tb` (and `@tbsl`) macro did nothing for non-PDF output,
simply passing through its argument.  However, within the `@pygments`
environment, which in turn is based on the `@format` environment, `makeinfo`
converts blank `--` to en-dashes (U+2013), which we don't want for LilyPond
code listings.
@Anteru Anteru added this to the 2.14.0 milestone Dec 30, 2022
tarsius pushed a commit to emacsmirror/lilypond that referenced this pull request Apr 16, 2023
Run

$ python scripts/auxiliar/update_pygments.py 2.14.0

and update python/auxiliar/vendored/README.md.

Pygments 2.14.0 contains improvements to LilyPond lexing, see
pygments/pygments#2283
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants