Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure "post" array is reversed relative to "pre" array #1

Open
bpj opened this issue Mar 27, 2021 · 0 comments
Open

Make sure "post" array is reversed relative to "pre" array #1

bpj opened this issue Mar 27, 2021 · 0 comments

Comments

@bpj
Copy link
Owner

bpj commented Mar 27, 2021

When formatting/concatenating the latex "post" markup we currently rely on the items in the post array to be just strings of closing curly brackets so that it doesn't matter in which order they are concatenated. To be safe against future additions to the post templates and against people copying the "algorithm" we should add a reverse_array helper function and call it on the post array before concatenating it.

local function reverse_array (arr)
  if 'table' == type(arr) then
    local rev = {}
    for i=#arr, 1, -1 do
      rev[#rev+1] = arr[i]
    end
    return rev
  end
  error"Expected argument to be table"
end

  post = table.concat( reverse_array(post) )
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

No branches or pull requests

1 participant