how to force a token type for mis-lexed parts #2608
Replies: 2 comments
-
for the time being, i reckon that i can also use "forced frozen cache" after semi-manually getting the tokenized result to be just like i want it to be. but that has to be done at the very last, as the document i am working on at the moment is going fast large changes |
Beta Was this translation helpful? Give feedback.
-
i think the two of these (with procedure, & delimiters other than it will only eeerror out in multilin comments, ... which itself i thiink can be easily avoided. |
Beta Was this translation helpful? Give feedback.
-
hi!
title/summary
how to force a token type for mis-parsed parts
details
psql
(postgresql shell) lexer as there's no lexer for mysql cli session.Generic.Output
, etc) on whole of the given text...similar to how there's guess mode for lexers, but then there's also ability to specify/force a lexer
orrrr..... maybe if there can be some other clever hack like say modifying the input file in some way to directly instruct pygments in some way.
related issues:
i remember reading somewhere something like "look into correctly parsing statement end comments"
but i can't recall where.pygments/pygments/lexers/sql.py
Lines 342 to 347 in 0f3ddb3
regex:
pygments/pygments/lexers/sql.py
Lines 271 to 278 in 0f3ddb3
regex summary relevant here:
->
;
versions:
2.17.2
(at the time of filing:2.16.1
)3.11.2
samples
following are the samples given in reverse chronological order:
meta delimiters (can't fix)
changes statement end delimiter from
;
to\G
(vertical output) or\p
(print command), regex keeps on looking for;
, bleeds outside till next query.the
\p
is very useful when using withsource
(\s
).also, again as with
\help
it capitalizes these above too, which is very bad in this context, as it contains normal queries, wherekeywordcase=upper
filter would be very much required.procedures (can't fix)
the procedure body uses delimiter
;
, regex stops there; marks the remaining portion of query too asGeneric.Output
separately treat help queries with
keywordcase=lower
filterthe "top" one produces wrong output, following one does correct
chang prompt to match regex
screenshot (for all the above samples:
Beta Was this translation helpful? Give feedback.
All reactions