Skip to content

Commit

Permalink
Merge pull request #27 from google/no-endl2
Browse files Browse the repository at this point in the history
Move normalize_newlines from test to parser
  • Loading branch information
ochafik authored Jan 21, 2025
2 parents b884069 + 437ec99 commit 1fcb266
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/minja/minja.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2419,7 +2419,7 @@ class Parser {
public:

static std::shared_ptr<TemplateNode> parse(const std::string& template_str, const Options & options) {
Parser parser(std::make_shared<std::string>(template_str), options);
Parser parser(std::make_shared<std::string>(normalize_newlines(template_str)), options);
auto tokens = parser.tokenize();
TemplateTokenIterator begin = tokens.begin();
auto it = begin;
Expand Down
4 changes: 2 additions & 2 deletions tests/test-chat-template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static std::string read_file(const std::string &path) {
std::string out;
out.resize(static_cast<size_t>(size));
fs.read(&out[0], static_cast<std::streamsize>(size));
return minja::normalize_newlines(out);
return out;
}

int main(int argc, char *argv[]) {
Expand Down Expand Up @@ -82,7 +82,7 @@ int main(int argc, char *argv[]) {

std::string expected;
try {
expected = read_file(golden_file);
expected = minja::normalize_newlines(read_file(golden_file));
} catch (const std::exception &e) {
std::cerr << "Failed to read golden file: " << golden_file << std::endl;
std::cerr << e.what() << std::endl;
Expand Down

0 comments on commit 1fcb266

Please sign in to comment.