[GH-ISSUE #26] Dumper does not preserve the formatting in Lua blocks. #11

Closed
opened 2026-02-28 01:20:29 +03:00 by kerem · 1 comment
Owner

Originally created by @tufanbarisyildirim on GitHub (Oct 18, 2023).
Original GitHub issue: https://github.com/tufanbarisyildirim/gonginx/issues/26

Originally assigned to: @tufanbarisyildirim on GitHub.

          if i have a block like this:
         set_by_lua_block $file_name {
                local t = ngx.var.uri
                local query = string.find(t, "?", 1)
                if query ~= nil then
                   t = string.sub(t, 1, query-1)
                end
                return t;
            }

then the code gonginx.DumpBlock(conf.Block, gonginx.IndentStyle) will dump this result:

   set_by_lua_block {


                            local t = ngx.var.uri local query = string.find(t, "?" , 1) if query ~= nil then t = string.sub(t, 1, query-1) end return t;


            }

it's worse when dump it several times @tufanbarisyildirim

Originally posted by @FeiYing9 in https://github.com/tufanbarisyildirim/gonginx/issues/20#issuecomment-1767876836

Originally created by @tufanbarisyildirim on GitHub (Oct 18, 2023). Original GitHub issue: https://github.com/tufanbarisyildirim/gonginx/issues/26 Originally assigned to: @tufanbarisyildirim on GitHub. if i have a block like this: ```nginx set_by_lua_block $file_name { local t = ngx.var.uri local query = string.find(t, "?", 1) if query ~= nil then t = string.sub(t, 1, query-1) end return t; } ``` then the code `gonginx.DumpBlock(conf.Block, gonginx.IndentStyle)` will dump this result: ```nginx set_by_lua_block { local t = ngx.var.uri local query = string.find(t, "?" , 1) if query ~= nil then t = string.sub(t, 1, query-1) end return t; } ``` it's worse when dump it several times @tufanbarisyildirim _Originally posted by @FeiYing9 in https://github.com/tufanbarisyildirim/gonginx/issues/20#issuecomment-1767876836_
kerem 2026-02-28 01:20:29 +03:00
  • closed this issue
  • added the
    v2
    label
Author
Owner

@tufanbarisyildirim commented on GitHub (Feb 20, 2026):

Thanks for reporting this. I re-checked against current main and this appears to be resolved now.

Verification I ran:

  • go test ./parser -run 'TestParser_Issue20|TestParser_Issue22' (passes)
  • Reproduced the set_by_lua_block sample and ran parse -> dump multiple times; output stays stable and preserves multiline Lua content instead of flattening it.

Closing this as fixed in current code.

<!-- gh-comment-id:3932140079 --> @tufanbarisyildirim commented on GitHub (Feb 20, 2026): Thanks for reporting this. I re-checked against current `main` and this appears to be resolved now. Verification I ran: - `go test ./parser -run 'TestParser_Issue20|TestParser_Issue22'` (passes) - Reproduced the `set_by_lua_block` sample and ran parse -> dump multiple times; output stays stable and preserves multiline Lua content instead of flattening it. Closing this as fixed in current code.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/gonginx#11
No description provided.