[WIP] Extended support for highlighting #109
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch:
(code:hilite code style-name)
@racket[(a . (b c))]
so that the dot is indeed shown if it were present in the source[(code:line . rest) #'rest]
. I'm not sure it's correct, though.(foo bar code:hilite baz)
renders as(foo bar . baz)
, with thebaz
highlighted.(foo bar code:hilite baz style-name)
should also work, and take into account the style name.code:line
, so that(code:line a b . c)
renders asa b . c
, just as(code:line a b c)
renders asa b c
.code:hilite
is misused (previously:"bad code:redex: ~.s"
, now:"bad code:hilite: ~.s"
).(set! src-col (add1 src-col))
forcode:hilite
when thesyntax-span
of the whole form is0
. This allows tools to wrap elements withcode:hilite
forms, without having an extra space. The tool needs to give the whole(code:hilite e)
form the same srcloc ase
, except for thesyntax-span
which is overridden with0
.These features / changes allow tools to highlight parts of the code, for example
sexp-diff
could be used to generate pretty diffs (such a tool would need to take care of srclocs, though), or to show before/after steps in literate programming. I wrote a small utility which does this:The bulk of the diff comes from moving
lloop
out of its formercond
case, so that it can be used both by the[(or (pair? (syntax-e c)) …
case and by thecode:line
case.Issues to solve before merging:
[(code:line . rest) #'rest]
is correct (first line of the diff). I think it won't cause any harm, but I'd like one of the scribble devs to double-check it.css-additions
outside of the code. I'm not sure how to embed a style without resorting to 3D syntax, or performing a dynamic-require of some sort. Ideas welcome!