diff options
author | Hans Hagen <pragma@wxs.nl> | 2016-10-14 17:42:58 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-10-14 17:42:58 +0200 |
commit | d273e996892fcf539d67c9548c90d96c2877507a (patch) | |
tree | 94cde76afdd112bd384f03a908ff0371ef27b5c9 /metapost | |
parent | 1964c078d21c5f1d19a84fa6ef5c038f8ee80652 (diff) | |
download | context-d273e996892fcf539d67c9548c90d96c2877507a.tar.gz |
2016-10-14 17:25:00
Diffstat (limited to 'metapost')
-rw-r--r-- | metapost/context/base/mpiv/mp-mlib.mpiv | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/metapost/context/base/mpiv/mp-mlib.mpiv b/metapost/context/base/mpiv/mp-mlib.mpiv index 9a4446560..39d74b352 100644 --- a/metapost/context/base/mpiv/mp-mlib.mpiv +++ b/metapost/context/base/mpiv/mp-mlib.mpiv @@ -1381,19 +1381,31 @@ vardef mfun_boolean_to_string(expr b) = if b : "true" else : "false" fi enddef ; -vardef tostring(expr value) = - if numeric value : mfun_numeric_to_string(value) - elseif pair value : mfun_pair_to_string(value) - elseif rgbcolor value : mfun_rgbcolor_to_string(value) - elseif cmykcolor value : mfun_cmykcolor_to_string(value) - elseif greycolor value : mfun_greycolor_to_string(value) - elseif boolean value : mfun_boolean_to_string(value) - elseif path value : mfun_path_to_string(value) - elseif transform value : mfun_transform_to_string(value) - else : value +vardef tostring primary v = + if numeric v : mfun_numeric_to_string(v) + elseif pair v : mfun_pair_to_string(v) + elseif rgbcolor v : mfun_rgbcolor_to_string(v) + elseif cmykcolor v : mfun_cmykcolor_to_string(v) + elseif greycolor v : mfun_greycolor_to_string(v) + elseif boolean v : mfun_boolean_to_string(v) + elseif path v : mfun_path_to_string(v) + elseif transform v : mfun_transform_to_string(v) + else : v fi enddef ; +vardef topair primary p = + if pair p : "(" & decimal xpart p & "," & decimal ypart p & ")" + elseif numeric p : "(" & decimal p & "," & decimal p & ")" + else : "" fi +enddef ; + +string dq ; dq := char 92 & char 34 ; +string sq ; sq := char 92 & char 39 ; + +vardef quote primary s = sq & tostring(s) & sq enddef; +vardef quotation primary s = dq & tostring(s) & dq enddef; + vardef mfun_tagged_string(expr value) = if numeric value : "1:" & mfun_numeric_to_string(value) elseif pair value : "4:" & mfun_pair_to_string(value) |