Skip to content

Commit

Permalink
Improve Ruby syntax highlighting
Browse files Browse the repository at this point in the history
It now passes torture tests sent to us by Jan Lelis from ruby.consulting
  • Loading branch information
jart committed Nov 9, 2024
1 parent 8915432 commit 5b0fff1
Show file tree
Hide file tree
Showing 6 changed files with 715 additions and 106 deletions.
7 changes: 6 additions & 1 deletion llamafile/highlight.h
Original file line number Diff line number Diff line change
Expand Up @@ -543,15 +543,20 @@ class HighlightRuby : public Highlight {
void flush(std::string *result) override;

private:
int c_ = 0;
int u_ = 0;
int t_ = 0;
int i_ = 0;
int level_ = 0;
int nesti_ = 0;
int expect_ = 0;
unsigned char q_ = 0;
unsigned char last_ = 0;
unsigned char opener_ = 0;
unsigned char closer_ = 0;
bool is_definition_ = 0;
bool pending_heredoc_ = false;
bool indented_heredoc_ = false;
unsigned char nest_[16];
std::string word_;
std::string heredoc_;
};
Expand Down
1 change: 1 addition & 0 deletions llamafile/highlight_js.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,5 +377,6 @@ void HighlightJs::flush(std::string *r) {
c_ = 0;
u_ = 0;
t_ = NORMAL;
expect_ = 0;
nesti_ = 0;
}
Loading

0 comments on commit 5b0fff1

Please sign in to comment.