Fossil

Diff
Login

Differences From Artifact [a1e920ddda]:

To Artifact [323dc1f8b2]:


66
67
68
69
70
71
72
73

74
75
76

77
78
79
80

81
82
83

84
85
86
87


88
89
90
91

92
93
94

95
96
97
98

99
100
101

102
103
104

105
106
107

108
109
110
111

112
113
114
115
116


117
118
119
120
121
122






123
124
125
126
127
128
129
130
131
132
133
134
135
136
137




138
139
140
141
142
143
144
145
146
147
148
149
150
151
152

153
154
155
156
157
158
159
160
161
66
67
68
69
70
71
72

73
74
75

76
77
78
79

80
81
82

83
84
85


86
87
88
89
90

91
92
93

94
95
96
97

98
99
100

101
102
103

104
105
106

107
108
109
110

111
112
113
114


115
116






117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136

137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154

155
156
157
158
159
160
161
162
163
164







-
+


-
+



-
+


-
+


-
-
+
+



-
+


-
+



-
+


-
+


-
+


-
+



-
+



-
-
+
+
-
-
-
-
-
-
+
+
+
+
+
+














-
+
+
+
+














-
+









      "box rad 10px \"Markdown\" \"Formatter\" \"(markdown.c)\" fit\n"
      "arrow right 200% \"HTML+SVG\" \"Output\"\n"
      "arrow <-> down from last box.s\n"
      "box same \"Pikchr\" \"Formatter\" \"(pikchr.c)\" fit\n";
  }
  style_header("PikchrShow");
  CX("<style>");
  CX("div.content { padding-top: 0.5em }");
  CX("div.content { padding-top: 0.5em }\n");
  CX("#sbs-wrapper {"
     "display: flex; flex-direction: column;"
     "}");
     "}\n");
  CX("#sbs-wrapper > * {"
     "margin: 0 0.25em 0.5em 0; flex: 1 10 auto;"
     "align-self: stretch;"
     "}");
     "}\n");
  CX("#sbs-wrapper textarea {"
     "max-width: initial; flex: 1 1 auto;"
     "}");
     "}\n");
  CX("#pikchrshow-output, #pikchrshow-form"
     "{display: flex; flex-direction: column; align-items: stretch;}");
  CX("#pikchrshow-form > * {margin: 0.25em 0}");
  CX("#pikchrshow-output {flex: 5 1 auto; padding: 0}");
  CX("#pikchrshow-form > * {margin: 0.25em 0}\n");
  CX("#pikchrshow-output {flex: 5 1 auto; padding: 0}\n");
  CX("#pikchrshow-output > pre, "
     "#pikchrshow-output > pre > div, "
     "#pikchrshow-output > pre > div > pre "
     "{margin: 0; padding: 0}");
     "{margin: 0; padding: 0}\n");
  CX("#pikchrshow-output.error > pre "
     /* Server-side error report */
     "{padding: 0.5em}");
     "{padding: 0.5em}\n");
  CX("#pikchrshow-controls {" /* where the buttons live */
     "display: flex; flex-direction: row; "
     "align-items: center; flex-wrap: wrap;"
     "}");
     "}\n");
  CX("#pikchrshow-controls > * {"
     "display: inline; margin: 0 0.25em 0.5em 0;"
     "}");
     "}\n");
  CX("#pikchrshow-output-wrapper label {"
     "cursor: pointer;"
     "}");
     "}\n");
  CX("body.pikchrshow .input-with-label > * {"
     "margin: 0 0.2em; cursor: pointer;"
     "}");
     "}\n");
  CX("#pikchrshow-output.dark-mode svg {"
     /* Flip the colors to approximate a dark theme look */
     "filter: invert(1) hue-rotate(180deg);"
     "}");
     "}\n");
  CX("#pikchrshow-output-wrapper {"
     "padding: 0.25em 0.5em; border-radius: 0.25em;"
     "border-width: 1px;"/*some skins disable fieldset borders*/
     "}");
  CX("#pikchrshow-output-wrapper > legend {"
     "}\n");
  CX("#pikchrshow-output-wrapper > legend > *:not(.copy-button){"
     "display: flex; flex-direction: row;"
     "align-items: center;"
     "}");
  CX("#pikchrshow-output-wrapper > legend > *:not(.copy-button)"
     "{margin-right: 0.5em}");
  CX(".dragover {border: 3px dotted rgba(0,255,0,0.6)}");
     "margin-right: 0.5em; vertical-align: middle;"
     "}\n");
  CX("body.pikchrshow .v-align-middle{"
     "vertical-align: middle"
     "}\n");
  CX(".dragover {border: 3px dotted rgba(0,255,0,0.6)}\n");
  CX("</style>");
  CX("<div>Input pikchr code and tap Preview to render it:</div>");
  CX("<div id='sbs-wrapper'>");
  CX("<div id='pikchrshow-form'>");
  CX("<textarea id='content' name='content' rows='15'>%s</textarea>",
     zContent/*safe-for-%s*/);
  CX("<div id='pikchrshow-controls'>");
  CX("<button id='pikchr-submit-preview'>Preview</button>");
  style_labeled_checkbox("flipcolors-wrapper", "flipcolors",
                         "Dark mode?",
                         "1", flipColors, 0);
  CX("</div>"/*#pikchrshow-controls*/);
  CX("</div>"/*#pikchrshow-form*/);
  CX("<fieldset id='pikchrshow-output-wrapper'>");
  CX("<legend></legend>");
  CX("<legend></legend>"
     /* Reminder: Firefox does not properly flexbox a LEGEND element,
        always flowing it in column mode (at least when its fieldset
        has a flexbox column layout). */);
  CX("<div id='pikchrshow-output'>");
  if(*zContent){
    int w = 0, h = 0;
    char *zOut = pikchr(zContent, "pikchr", 0, &w, &h);
    if( w>0 && h>0 ){
      const char *zNonce = safe_html_nonce(1);
      CX("%s<div style='max-width:%dpx;'>\n%s</div>%s",
         zNonce, w, zOut, zNonce);
    }else{
      CX("<pre>\n%s\n</pre>\n", zOut);
    }
    fossil_free(zOut);
  }
  CX("</div>"/*#pikchrshow-output*/);
  CX("</fieldset>");
  CX("</fieldset>"/*#pikchrshow-output-wrapper*/);
  CX("</div>"/*sbs-wrapper*/);
  if(!builtin_bundle_all_fossil_js_apis()){
    builtin_emit_fossil_js_apis("dom", "fetch", "copybutton",
                                "popupwidget", 0);
  }
  builtin_emit_fossil_js_apis("page.pikchrshow", 0);
  builtin_fulfill_js_requests();
  style_footer();
}