diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-03-22 13:56:31 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-03-22 13:56:35 -0700 |
| commit | 9109a090eb7063b7e90f5c6507ec6cb8e6a499e0 (patch) | |
| tree | f4a9a23ff5db9fa4b8fb670ef3d4f25fc3bf7a6a | |
| parent | 972de38421d14882de192ddbd51afd89c4ffb06c (diff) | |
Better repr.
| -rw-r--r-- | utils.lua | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -30,6 +30,8 @@ local max = math.max local _quote_patt = re.compile("(({'\n' / '\"' / \"'\" / '\\'}->mark_char) / (']' ({'='*}->mark_eq) (']' / !.)) / .)*", {mark_char=function(q) if q == "\n" or q == "\\" then + _quote_state["'"] = false + _quote_state['"'] = false if _quote_state.min_eq == nil then _quote_state.min_eq = 0 end @@ -74,9 +76,9 @@ local function repr(x, depth) end _quote_state = {} _quote_patt:match(x) - if _quote_state["'"] ~= false and _quote_state.min_eq == nil then + if _quote_state["'"] ~= false then return "\'" .. x .. "\'" - elseif _quote_state['"'] ~= false and _quote_state.min_eq == nil then + elseif _quote_state['"'] ~= false then return "\"" .. x .. "\"" else local eq = ("="):rep(_quote_state.min_eq or 0) |
