FIxing the README in highlight (#501)

* Correct README.md in /highlight

correct the lifetime in highlighter.highlight and correct the cases in match so that the demo in README could work.

* Update README.md

another small fix

* Update highlight/README.md

Co-Authored-By: Max Brunsfeld <maxbrunsfeld@github.com>
This commit is contained in:
Han BAO 2019-12-06 15:05:28 -06:00 committed by Max Brunsfeld
parent 2758103646
commit acc5f092c8

View file

@ -80,22 +80,22 @@ Highlight some code:
use tree_sitter_highlight::HighlightEvent;
let highlights = highlighter.highlight(
javascript_config,
&javascript_config,
b"const x = new Y();",
None,
&|_| None
|_| None
).unwrap();
for event in highlights {
match event? {
HighlightEvent::Source(s) {
eprintln!("source: {:?}", s);
HighlightEvent::Source {start, end} => {
eprintln!("source: {}-{}", start, end);
},
HighlightEvent::HighlightStart(s) {
eprintln!("highlight style started: {:?}", s);
},
HighlightEvent::HighlightEnd(s) {
eprintln!("highlight style ended: {:?}", s);
HighlightEvent::HighlightEnd {
eprintln!("highlight style ended");
},
}
}