Skip to content

Conversation

@juj
Copy link
Collaborator

@juj juj commented Jan 7, 2026

E.g. a JS library function containing

var string = `abc
def
ghi`;

would incorrectly be emitted as

  var string = `abc
  def
  ghi`;

(i.e. "abc\n def\n ghi")

when the output JS was generated, changing the contents of the multiline string.

@juj juj force-pushed the fix_multiline_string_indentation branch from b9bf767 to be74046 Compare January 7, 2026 18:02
Copy link
Collaborator

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm % comments

'closure': (['--closure', '1'],),
})
def test_multiline_string(self, args):
self.do_run_in_out_file_test('test_multiline_string.c', cflags=['--js-library', test_file('test_multiline_string.js')] + args)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add this test instead to test/test_jslib.js?

if (text[i] == '\n') out += indent;
}
return text.replace(/\n/g, `\n${indent}`);
return out;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I wonder at what point we should just acorn for this rather than adding complexity here? Or maybe we should just skip this process completely when the string contains any backticks at all?

@@ -0,0 +1,10 @@
#include <stdio.h>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this files to test/jslib?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants