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

LWS-264: Lxlquery grammar and highlighting #1159

Merged
merged 8 commits into from
Nov 15, 2024

Conversation

jesperengstrom
Copy link
Contributor

@jesperengstrom jesperengstrom commented Nov 13, 2024

Description

Tickets involved

LWS-264

Summary of changes

  • Add rudimentary language rules to the grammar file
  • Add tests for the grammar
  • Parse the language with custom lezer Tags for certain nodes
  • Add codemirror extension that adds CSS classes when encountering those tags
  • Add a css file to style those classes, achieving syntax highlighting

try some searches from the help page:
pippi långstrump språk:(engelska OR franska) ÅR>2002]
språk:svenska ÅR>2010 ÅR<=2024 ämne:"sao:Drakar"
träd* bibliografi:"sigel:DST" NOT typ:Text

Or a 'special' qualifier
includeEplikt

Notes:

  • The (somewhat) straighforward way of highlighting using nodes -> tags -> classes/styles seems to be the cheapest (compared to iterating through the syntax tree adding decorators - even though we'll be doing that later on) but is limited in that it does not produce nested structures, only an inline element for the most specific exported node in a given place. On the other hand, I don't know if we want/need highlighting at all. But for now I think it's nice for evaluating/debugging purposes. The styling itself is not carefully done :)

  • The highlighter extension now belongs to lxlweb. Since it's language specific, it doesn't belong to supersearch and is not a core part of the language either. It imports stuff from codemirror/lezer that lxlweb does not directly depend on, don't know if that's a problem?

(Another solution could be to let the language package export the Highlighter, import it in lxlweb and pass it as a special prop (how many can we handle?) to supersearch that then turns it into an extension.)

@jesperengstrom jesperengstrom marked this pull request as ready for review November 13, 2024 10:43
Copy link
Contributor

@johanbissemattsson johanbissemattsson left a comment

Choose a reason for hiding this comment

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

Really awesome work! 🌟 🙌 I think it would be good to go through the grammar together with the rest of the team (can be done after the PR is merged; we can then also discuss the possible use of brackets to separate the qualifiers) but I think it looks really good in it's current state!

lxl-web/src/lib/utils/LxlQueryHighlight.ts Outdated Show resolved Hide resolved
lxl-web/src/lib/utils/LxlQueryHighlight.ts Outdated Show resolved Hide resolved
@jesperengstrom jesperengstrom force-pushed the feature/supersearch-lxl-query-grammar branch from aa4352f to 124e63e Compare November 14, 2024 12:56
@jesperengstrom jesperengstrom merged commit 1ebbd1d into develop Nov 15, 2024
4 checks passed
@jesperengstrom jesperengstrom deleted the feature/supersearch-lxl-query-grammar branch November 15, 2024 09:56
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.

2 participants