TITLE
Ugly display of “pre” blocks
(I had to take wraping pre in <code;> to get title acceptible)
Display of <pre> is rather ugly with all the extra white space. It really needs some CSS styling.
(LETS SEE If I can directly put in a <style> block and change it)
<style>pre { white-space: pre-wrap; border-left-width-value: 6px; border-left-style-value: solid; border-left-color-value: rgb(200, 200, 170); padding-top: 8px; padding-right-value: 8px; padding-bottom: 8px; padding-left-value: 16px; background-color: rgb(235, 236, 255); margin-top: 1em; margin-right-value: 0pt; margin-bottom: 1em; margin-left-value: 0pt;}</style>
(ANY BETTER?)
o = {a: 1,
b: 2
}
The Javascript syntax coloring is the same but only colored. (I recall that I had to put in a “The” at the start of this pgh so I wouldn’t get a parse error.)
o = {a: 1,
b: 2
}
Working Ampersand Escaping
Example showing correct ampersand escaping in ID attribute, td as textnode, td containg XML. Note that spaces are INCORRECTLY stripped from around QUOT APOS and the code item.
<!-- 2c -->| id | | NEW |
| type | | category |
| page | | Rod McGuire |
| !AsXML | | |
| junk | | a’b”c < d > e & f |
| junkX | | a’b”cXxXd & e |
Captions in Tables
Giving table captions example. A caption property can be plain text (!Caption) where the characters ”<” and ”>” can appear but wind up being escaped, or XML (!XMLCaption) where those brackets if they appear are assumed to delimit XHTML entities such as <code>.
{"!Caption": "top caption",
id: "test1",
a: "x",
b: {c: {d: "y", e: "z", "!XMLCaption": "internal XML caption"},
f: "w"},
}
{"!Caption":"top caption","id":"test1","a":"x","b":{"c":{"d":"y","e":"z","!XMLCaption":"internal <code>XML</code> caption"},"f":"w"}}
(THE jso shown above may not have been correctly updated to reflect this example that works)
top caption
<!-- 2c -->| !Caption | | top caption |
| id | | test1 |
| a | | x |
| b | |
<!-- 2c -->| c | | internalXMLcaption
<!-- 2c -->| d | | y | | e | | z | | !XMLCaption | | internalXMLcaption | | | f | | w | |
2 column vs. 1 column
3) 2 column vs 1 column-with-header display examples.
2 column
{a: "x",
b: {c: {d: "y", e: "z"},
f: "w"},
}
{"a":"x","b":{"c":{"d":"y","e":"z"},"f":"w"}}
Some internal 1 columns
Example with some internal objects displayed in 1 column-with-header (full display)
{a: "x",
b: {"!Columns": 1,
c: {"!Columns": 1, d: "y", e: "z"},
f: "w"},
}
{"a":"x","b":{"!Columns":1,"c":{"!Columns":1,"d":"y","e":"z"},"f":"w"}}
1 column with !NoBang
3c) 1 column-with-header with top level !NoBang: 1 that suppresses property names that start with bang (!).
{"!NoBang": 1,
a: "x",
b: {"!Columns": 1,
c: {"!Columns": 1, d: "y", e: "z"},
f: "w"},
}
{"!NoBang":1,"a":"x","b":{"!Columns":1,"c":{"!Columns":1,"d":"y","e":"z"},"f":"w"}}
!Label examples with sometimes !Atom wrappers
!Label 2 column
{"a":"x","b":{"!Label":"pp","c":{"d":"y","e":{"!Atom":"z", "!Label":"qq"},"f":"w"}}}
<!-- 2c -->| a | | x |
| b | pp |
<!-- 2c -->| !Label | | pp | | c | |
<!-- 2c -->| d | | y | | e | qq |
<!-- 2c -->| !Atom | | z | | !Label | | qq | | | f | | w | | |
!Label 2 column !NoBang
{"!NoBang":"1","a":"x","b":{"!Label":"pp","c":{"d":"y","e":{"!Atom":"z", "!Label":"qq"},"f":"w"}}}
!Label 1 column
{"!Columns":"1","a":"x","b":{"!Label":"pp","c":{"d":"y","e":{"!Atom":"z", "!Label":"qq"},"f":"w"}}}
!Label 1 column !NoBang
{"!Columns":"1","!NoBang":"1","a":"x","b":{"!Label":"pp","c":{"d":"y","e":{"!Atom":"z", "!Label":"qq"},"f":"w"}}}
Array example
It looks here that JSON.stringify and JSON.parse really don’t know how to handle arrays.
x = {a: [['b', 'c'], ['d', 'e']]};
x.a[0];
=> b,c
s = JSON.stringify(x)
=> {"a":"[[\"b\", \"c\"], [\"d\", \"e\"]]"}
os = JSON.parse(s)
=> [object Object]
uneval(os)
=> ({a:"[[\"b\", \"c\"], [\"d\", \"e\"]]"})
os.a[0]
=> [
<!-- 2c -->| a | | [[”b”, “c”], ”d”, “e”] |
hand fed example to show the GM script is working
x = {a: [['b', 'c'], ['d', 'e']]};
genEntry(x) =>
Types with Recursive Structure
type “pair” in full
Define “pair”.
p = {Type: {"!Atom": "pair structure",
"!Label": "t"},
"!Label": "pair",
part: {1: {"!Label": "p1",
Type: " structure"},
2: {"!Label": "p2",
Type: " structure"},
},
swapped: {Type: {},
part: {},
swapped: {},
},
Notes: "See [[ordered pair]].",
};
p.swapped.Type = p.Type;
p.swapped.part[1] = p.part[2];
p.swapped.part[2] = p.part[1];
p.swapped.swapped = p;
pn = eval(uneval(p)); // clone it
pn['!NoBang'] = 1;
Generated ID for pn:
rEsc(pn) =>
#4={Type:#1={'!Atom':"pair < structure", '!Label':"t"}, '!NoBang':1, '!Label':"pair", part:{1:#3={'!Label':"p1", Type:"< structure"}, 2:#2={'!Label':"p2", Type:"< structure"}}, swapped:{Type:#1#, part:{1:#2#, 2:#3#}, swapped:#4#}, Notes:"See [[ordered pair]]."}
Generated table for p:
| ?pair | | Type | | | !NoBang | | | !Label | | | part | | | swapped | | | Notes | | | !Seen | |
|
Generated table for pn:
Various types
“pair”
A pair has two parts. The map “swapped” (aka. “transpose”) switches the parts, and .
“twin”, a subtype of “pair”
A twin is a pair in which both components are the same.
t = eval(uneval(p)) // clone "pair"
t.Type['!Atom'] = "twin pair structure";
t.part[2] = t.part[1];
t.swapped = t;
Essentially , though this formulation doesn’t notice that “swapped” is now an identity.
| ?pair | | Type | | ?t | twin < pair < structure |
| | part | | | swapped | | | Notes | |
|
any “structure” can be twinned
A small definition of this is:
Then with type inference from “twin”, essentially , this becomes:
s1 = eval(uneval(s0)); // clone
s1.twinned.part[2] = s1.twinned.part[1];
s1.twinned.swapped = s1.twinned;
as
cartesian product as a type
take 1
c1.from.part[1].generic_member.in = c1.from.part[1]; c1.from.part[2].generic_member.in = c1.from.part[2]; c1.to.generic_member.in = c1.to; c1.to.generic_member.part[1] = c1.from.part[1].generic_member; c1.to.generic_member.part[2] = c1.from.part[2].generic_member; c1.projection[1].from = c1.to; c1.projection[1].to = c1.from.part[1]; c1.projection[2].from = c1.to; c1.projection[2].to = c1.from.part[2];
| | Type | | cartesian product < isomorphism < arrow |
| | from | | | to | | | projection | | | Notes | |
|
The END.