nLab
Rod McGuire

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><![CDATA[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 -->
idNEW
typecategory
pageRod McGuire
!AsXML <!-- 2c -->
junkX1
junka ' b " c < d > e & f
junkXa ' b " c XxX d & 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)

<!-- 2c -->
top caption
!Captiontop caption
idtest1
ax
b <!-- 2c -->
c <!-- 2c -->
internal XML caption
dy
ez
!XMLCaptioninternal <code>XML</code> caption
fw

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"}}
<!-- 2c -->
ax
b <!-- 2c -->
c <!-- 2c -->
dy
ez
fw

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"}}

<!-- 2c -->
ax
b <!-- 1c -->
!Columns
1
c
<!-- 1c -->
!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"}}

<!-- 2c -->
ax
b <!-- 1c -->
c
<!-- 1c -->
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 -->
ax
bpp <!-- 2c -->
!Labelpp
c <!-- 2c -->
dy
eqq <!-- 2c -->
!Atomz
!Labelqq
fw

!Label 2 column !NoBang

{"!NoBang":"1","a":"x","b":{"!Label":"pp","c":{"d":"y","e":{"!Atom":"z", "!Label":"qq"},"f":"w"}}}
<!-- 2c -->
ax
bpp <!-- 2c -->
c <!-- 2c -->
dy
eqqz
fw

!Label 1 column

{"!Columns":"1","a":"x","b":{"!Label":"pp","c":{"d":"y","e":{"!Atom":"z", "!Label":"qq"},"f":"w"}}}
<!-- 1c -->
!Columns
1
a
x
b
pp <!-- 1c -->
!Label
pp
c
<!-- 1c -->
d
y
e
qq <!-- 1c -->
!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"}}}
<!-- 1c -->
a
x
b
pp <!-- 1c -->
c
<!-- 1c -->
d
y
e
qqz
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) =>
<!-- 2c -->
a <!-- 2c -->
0 <!-- 2c -->
0b
1c
1 <!-- 2c -->
0d
1e

Types with Recursive Structure

type “pair” in full

Define “pair”.

p = {Type:      {"!Atom": "pair 

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
?t
!Atom
pair < structure
!Label
t
!Seen
1
!NoBang
0
!Label
pair
part
1
?p1
!Label
p1
Type
< structure
!Seen
1
2
?p2
!Label
p2
Type
< structure
!Seen
1
!Seen
1
swapped
Type
?t...
part
1
?p2...
2
?p1...
!Seen
1
swapped
?pair...
!Seen
1
Notes
See ordered pair.
!Seen
1

Generated table for pn:

?pair
Type
?tpair < structure
part
1
?p1
Type
< structure
2
?p2
Type
< structure
swapped
Type
?tpair < structure
part
1
?p2...
2
?p1...
swapped
?pair...
Notes
See ordered pair.

Various types

“pair”

A pair has two parts. The map “swapped” (aka. “transpose”) switches the parts, and swapped(swapped(p))=pswapped(swapped(p)) = p.

?pair
Type
?tpair < structure
part
1
?p1
Type
< structure
2
?p2
Type
< structure
swapped
Type
?tpair < structure
part
1
?p2...
2
?p1...
swapped
?pair...
Notes
See ordered pair.

“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 

Essentially twin=pair(?p1=?p2)twin = pair \wedge (?p1 = ?p2), though this formulation doesn’t notice that “swapped” is now an identity.

?pair
Type
?ttwin < pair < structure
part
1
?p1
Type
< structure
2
?p1...
swapped
?pair...
Notes
See ordered pair.

any “structure” can be twinned

A small definition of this is:

?s
Type
structure
twinned
?tw
Type
< twin
part
1
?s...

Then with type inference from “twin”, essentially s.twinned=s.twinnedtwins.twinned = s.twinned \wedge twin, this becomes:

s1 = eval(uneval(s0)); // clone
s1.twinned.part[2] = s1.twinned.part[1];
s1.twinned.swapped = s1.twinned;

as

?s
Type
structure
twinned
?tw
Type
< twin
part
1
?s...
2
?s...
swapped
?tw...

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
Type
< pair
part
1
?s1
Type
< set
generic_member
?m1
quant
any
in
?s1...
2
?s2
Type
< set
generic_member
?m2
quant
any
in
?s2...
to
?p
Type
< set
generic_member
Type
< pair
quant
any
in
?p...
part
1
?m1...
2
?m2...
projection
1
from
?p...
to
?s1...
2
from
?p...
to
?s2...
Notes
See cartesian product.

The END.

category: people

Revised on September 12, 2010 21:40:14 by Rod Mc Guire (68.162.154.160)