Skip to content

Distribute and run LLMs with a single file.

Fix regression in markdown bulleted lists

Justine Tunney88b0ece953db
diff --git a/llamafile/highlight.h b/llamafile/highlight.h
index 5bae34f3..8c409abf 100644
--- a/llamafile/highlight.h
+++ b/llamafile/highlight.h
@@ -210,6 +210,7 @@ class HighlightMarkdown : public Highlight {
private:
int t_ = 0;
+ bool bol_ = true;
bool tail_ = false;
std::string lang_;
Highlight *highlighter_ = nullptr;
diff --git a/llamafile/highlight_markdown.cpp b/llamafile/highlight_markdown.cpp
index b4cdefd8..3b0b9533 100644
--- a/llamafile/highlight_markdown.cpp
+++ b/llamafile/highlight_markdown.cpp
@@ -64,7 +64,14 @@ void HighlightMarkdown::feed(std::string *r, std::string_view input) {
} else {
*r += c;
}
- tail_ = c != '\n';
+ if (c == '\n') {
+ bol_ = true;
+ tail_ = false;
+ } else {
+ tail_ = true;
+ if (!isblank(c))
+ bol_ = false;
+ }
break;
case BACKSLASH:
@@ -79,6 +86,10 @@ void HighlightMarkdown::feed(std::string *r, std::string_view input) {
*r += HI_BOLD;
*r += '*';
*r += c;
+ } else if (bol_ && isblank(c)) {
+ *r += '*';
+ *r += c;
+ t_ = NORMAL;
} else {
// handle *emphasized* text
// inverted because \e[3m has a poorly supported western bias