diff --git a/fixtures/0003-leave-php-context.php b/fixtures/0003-leave-php-context.php
index be8cb8b..8b2b52b 100644
--- a/fixtures/0003-leave-php-context.php
+++ b/fixtures/0003-leave-php-context.php
@@ -4,11 +4,16 @@ $header = "bar";
?>
-
-
=$header?>
-
+
+
+
+
+
+ =$header?>
+
+
+
diff --git a/node.go b/node.go
index 75c030d..3b2e0a8 100644
--- a/node.go
+++ b/node.go
@@ -379,9 +379,17 @@ func convert(n_ node.Node) (string, error) {
case *stmt.InlineHtml:
// Convert into fmt.Print
- // TODO the result from strconv.Quote is not that nice to maintain if there are multiple newlines
- // Should convert it into a backtick-delimeted multiline string instead
- return "fmt.Print(" + strconv.Quote(n.Value) + ")\n", nil // newline - standalone statement
+
+ var quoted string
+ if !strings.Contains(n.Value, "`") && strings.Count(n.Value, "\n") >= 3 { // TODO make the heuristic configurable
+ // Use backtick-delimited multiline string
+ quoted = "`" + n.Value + "`"
+ } else {
+ // Can't trivially represent it with backticks, or it's not multiline "enough" to bother - use full Go quoting
+ quoted = strconv.Quote(n.Value)
+ }
+
+ return "fmt.Print(" + quoted + ")\n", nil // newline - standalone statement
case *stmt.Nop:
return "", nil