Welcome to mirror list, hosted at ThFree Co, Russian Federation.

specification_html_template.erb « glfm « lib « scripts - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f75cb4002294286d049c0cd3f0c8de7029c0c818 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
<!DOCTYPE html>
<!-- NOTE: Styling is based on the CommonMark specification template:                -->
<!-- - https://github.com/commonmark/commonmark-spec/blob/master/tools/make_spec.lua -->
<!-- - https://github.com/commonmark/commonmark-spec/blob/master/tools/template.html -->
<!--                                                                                 -->
<!-- NOTE: 'TODO:' comments will be followed up as task(s) on this issue:            -->
<!-- - https://gitlab.com/gitlab-org/gitlab/-/issues/361241                          -->
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title><%= title %></title>
  <style type="text/css">
    body {
      font-family: Helvetica, arial, freesans, clean, sans-serif;
      line-height: 1.4;
      max-width: 48em;
      margin: auto;
      padding: 0 0.5em 4em;
      color: #333333;
      background-color: #ffffff;
      font-size: 13pt;
    }

    div#TOC ul { list-style: none; }
    h1 {
      font-size: 140%;
      font-weight: bold;
      border-top: 1px solid gray;
      padding-top: 0.5em;
    }

    h2 {
      font-size: 120%;
      font-weight: bold;
    }

    h3 {
      font-size: 110%;
      font-weight: bold;
    }

    h4 {
      font-size: 100%;
      font-weight: bold;
    }

    /* NOTE: "font-weight: bold" was applied to "a.definition" class in original CommonMark */
    /*       template, but in practice it was applied to all anchors                        */
    a {
      font-weight: bold;
    }


    /* TODO: Format whitespace in examples. This will require preprocessing to insert spans around them. */
    /*span.space { position: relative; }*/
    /*span.space:after {*/
    /*  content: "·";*/
    /*  position: absolute;*/
    /*  !* create a mark that indicates a space (trick from D. Greenspan) *!*/
    /*  top: 0; bottom: 7px; left: 1px; right: 1px;*/
    /*  color: #aaaaaa;*/
    /*}*/
    /*@media print {*/
    /*  a.dingus { display: none; }*/
    /*}*/

    div.example {
      overflow: hidden;
    }

    p {
      text-align: justify;
    }

    pre {
      padding: 0.5em;
      margin: 0.2em 0 0.5em;
      font-size: 88%;
    }

    pre {
      white-space: pre-wrap; /* css-3 */
      white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
      white-space: -o-pre-wrap; /* Opera 7 */
      word-wrap: break-word; /* Internet Explorer 5.5+ */
    }

    code {
      font-family: monospace;
      background-color: #d3e1e4;
    }

    pre > code {
      background-color: transparent;
    }

    .example {
      font-size: 0; /* hack to get width: 50% to work on inline-block */
      padding-bottom: 6pt;
    }

    .column pre {
      font-size: 11pt;
      padding: 2pt 6pt;
    }

    div.examplenum {
      font-size: 11pt;
      text-align: left;
      margin-bottom: 10px;
    }

    div.column {
      display: inline-block;
      width: 50%;
      vertical-align: top;
    }

    div.example > div:nth-child(2) {
      clear: left;
      background-color: #d3e1e4;
    }

    div.example > div:nth-child(3) {
      clear: right;
      background-color: #c9cace;
    }

    @media print {
      @page {
        size: auto;
        margin: 1.2in 1.2in 1.2in 1.2in;
      }

      body {
        margin: 0;
        line-height: 1.2;
        font-size: 10pt;
      }

      .column pre {
        font-size: 9pt;
      }

      div.examplenum {
        font-size: 9pt;
      }
    }
  </style>
  <!-- TODO: Extract this javascript out to a separate file and unit test it -->
  <script type="text/javascript">
    /* NOTE: The following code performs many of the pre-processing steps originally handled */
    /* in https://github.com/commonmark/commonmark-spec/blob/master/tools/make_spec.lua      */

    /* Adds a div.example wrapper around each pair of example code blocks. */
    function addAttributesToExampleWrapperDivs() {
      const exampleAnchorTags = document.querySelectorAll("a[href^=\"#example-\"]");
      for (const exampleAnchorTag of exampleAnchorTags) {
        const examplenumDiv = exampleAnchorTag.parentElement;
        examplenumDiv.classList.add("examplenum");
        const exampleDiv = examplenumDiv.parentElement;
        exampleDiv.classList.add("example");
        exampleDiv.id = exampleAnchorTag.getAttribute("href").substring(1);
      }
    }

    function addColumnClassToMarkdownDivs() {
      const markdownCodeBlockDivs = document.querySelectorAll("div.markdown-code-block");
      for (const markdownCodeBlockDiv of markdownCodeBlockDivs) {
        markdownCodeBlockDiv.classList.add("column");
      }
    }

    function addNumbersToHeaders() {
      const headers = document.querySelectorAll('h1,h2,h3');
      let h1Index = -1; // NOTE: -1 because we don't assign a number to the title
      let h2Index = 0;
      let h3Index = 0;
      const tocEntries = [];
      for (const header of headers) {
        if (h1Index === -1) {
          h1Index++;
          continue;
        }

        const originalHeaderTextContent = header.textContent.trim();
        const headerAnchor = originalHeaderTextContent.toLowerCase().replaceAll(' ', '-');
        header.id = headerAnchor;
        let indent;
        let headerTextContent;
        if (header.tagName === 'H1') {
          h1Index++;
          h2Index = 0;
          h3Index = 0;
          header.textContent = headerTextContent = h1Index + ' ' + originalHeaderTextContent;
          indent = 0;
        } else if (header.tagName === 'H2') {
          h2Index++;
          h3Index = 0;
          header.textContent =
            headerTextContent = h1Index + '.' + h2Index + ' ' + originalHeaderTextContent;
          indent = 1;
        } else if (header.tagName === 'H3') {
          h3Index++;
          header.textContent = headerTextContent =
            h1Index + '.' + h2Index + '.' + h3Index + ' ' + originalHeaderTextContent;
          indent = 2;
        }
        tocEntries.push({headerAnchor, headerTextContent, indent});
      }
    }

    document.addEventListener("DOMContentLoaded", function(_event) {
      addAttributesToExampleWrapperDivs();
      addColumnClassToMarkdownDivs();
      const tocEntries = addNumbersToHeaders();
      addToc(tocEntries);
    });

    /* NOTE: The following code is to support the "Try it" interactive "dingus", which        */
    /*       we do not yet support. But it is being left here for comparison context with the */
    /*       original CommonMark template.                                                    */
    // $$(document).ready(function() {
    //   $$("div.example").each(function(e) {
    //     var t = $$(this).find('code.language-markdown').text();
    //     $$(this).find('a.dingus').click(function(f) {
    //       window.open('/dingus/?text=' +
    //         encodeURIComponent(t.replace(/→/g,"\t")));
    //     });
    //   });
    //   $$("code.language-markdown").dblclick(function(e) { window.open('/dingus/?text=' +
    //     encodeURIComponent($$(this).text()));
    //   });
    // });
  </script>
</head>
<body>
<h1 class="title"><%= title %></h1>
<div class="version">Version <%= version %></div>

<%= body %>

</body>
</html>