mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-24 22:04:56 +00:00
- Added CSV export functionality with escape handling. - Implemented JSON export functionality. - Created utility functions for retrieving column labels and row values. - Established a filtering system with state management and filter application. - Refactored sorting logic into dedicated modules for better maintainability. - Deprecated old filtering and sorting files, redirecting to new module structure. - Introduced form field builders and validation utilities, also refactored into single-function files.
29 lines
563 B
Lua
29 lines
563 B
Lua
-- Escape a value for CSV
|
|
-- Single function module for data table export
|
|
|
|
---@class EscapeCsv
|
|
local M = {}
|
|
|
|
---Escape a value for CSV
|
|
---@param value any Value to escape
|
|
---@return string Escaped CSV string
|
|
function M.escapeCsv(value)
|
|
if value == nil then
|
|
return ""
|
|
end
|
|
|
|
local str = tostring(value)
|
|
|
|
-- Check if escaping is needed
|
|
if string.find(str, '[,"\r\n]') then
|
|
-- Escape double quotes by doubling them
|
|
str = string.gsub(str, '"', '""')
|
|
-- Wrap in double quotes
|
|
str = '"' .. str .. '"'
|
|
end
|
|
|
|
return str
|
|
end
|
|
|
|
return M
|