Fossil

Changes On Branch markdown-header-ids
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch markdown-header-ids Excluding Merge-Ins

This is equivalent to a diff from 5590fb9e to 61186d21

2019-12-16
13:50
Backed out [c903fbc39e] (addition of "header-") prefix after sleeping on what Warren brought up in forum post f244b452fccd460a0. Edit: closing based on discussion in http://fossil-scm.org/forum/forumpost/097eca7dd9 (summary: we should do it like pandoc does). ... (Closed-Leaf check-in: 61186d21 user: stephan tags: markdown-header-ids)
2019-12-15
15:26
Added "heading-" prefix to generated IDs to help avoid accidental collisions with manually-added anchors. ... (check-in: c903fbc3 user: stephan tags: markdown-header-ids)
2019-12-13
20:56
If path given to /ext is a directory and it contains an index file (of the same names supported by the /doc path), render that index file. Edit: closing branch b/c Richard implemented the same thing in parallel in [3ed3fa3dda9c6d6f]. ... (Closed-Leaf check-in: f28cea2b user: stephan tags: ext-render-index)
18:57
Enhance the /ext page to search for "index.*" files if the pathname ends with "/" and is a directory name. ... (check-in: 3ed3fa3d user: drh tags: trunk)
13:06
Markdown-to-HTML now adds automatically-generated ID attributes to the headers to facilitate creating intra-document links and hyperlinked tables of contents. The ID algorithm is simply to lower-case all ASCII alphanumeric characters in the header text. ... (check-in: 88eb24a9 user: stephan tags: markdown-header-ids)
06:06
Added webp mimetype, a pedantic constness tweak in the mimetype table, and a minor typo fix. ... (check-in: 5590fb9e user: stephan tags: trunk)
2019-12-11
12:43
Rename the CGI control file variable "debug:" to "cgi-debug:" and enhance it so that it shows the complete CGI environment at the start of each request. Also add documentation. ... (check-in: 4a7760e3 user: drh tags: trunk)

Changes to src/markdown_html.c.
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

static void html_blockquote(struct Blob *ob, struct Blob *text, void *opaque){
  INTER_BLOCK(ob);
  BLOB_APPEND_LITERAL(ob, "<blockquote>\n");
  BLOB_APPEND_BLOB(ob, text);
  BLOB_APPEND_LITERAL(ob, "</blockquote>\n");
}



















static void html_header(
  struct Blob *ob,
  struct Blob *text,
  int level,
  void *opaque
){
  struct Blob *title = opaque;

  /* The first header at the beginning of a text is considered as
   * a title and not output. */
  if( blob_size(ob)<=PROLOG_SIZE && title!=0 && blob_size(title)==0 ){
    BLOB_APPEND_BLOB(title, text);
    return;
  }

  INTER_BLOCK(ob);



  blob_appendf(ob, "<h%d>", level);

  BLOB_APPEND_BLOB(ob, text);
  blob_appendf(ob, "</h%d>", level);

}

static void html_hrule(struct Blob *ob, void *opaque){
  INTER_BLOCK(ob);
  BLOB_APPEND_LITERAL(ob, "<hr />\n");
}








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>








>






>

>
>
>
|
>


>







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

static void html_blockquote(struct Blob *ob, struct Blob *text, void *opaque){
  INTER_BLOCK(ob);
  BLOB_APPEND_LITERAL(ob, "<blockquote>\n");
  BLOB_APPEND_BLOB(ob, text);
  BLOB_APPEND_LITERAL(ob, "</blockquote>\n");
}

/*
** For each byte of pIn which is an ASCII alphanumeric, its lowercase
** form is appended to pOut. The intent is to generate an automated
** HTML ID attribute from, e.g., header text, in particular an ID
** which a human could easily recreate "in their head" while writing a
** document, to facilitate the create of intra-document links.
*/
static void html_text_to_id(Blob const * pIn, Blob *pOut){
  int i;
  unsigned char const * z = (unsigned char const *)pIn->aData;
  for( i = 0; i < pIn->nUsed; ++i, ++z ){
    if(*z<128 && fossil_isalnum(*z)){
      char const Z = (char)fossil_tolower(*z);
      blob_append(pOut, &Z, 1);
    }
  }
}

static void html_header(
  struct Blob *ob,
  struct Blob *text,
  int level,
  void *opaque
){
  struct Blob *title = opaque;
  Blob bId = empty_blob;
  /* The first header at the beginning of a text is considered as
   * a title and not output. */
  if( blob_size(ob)<=PROLOG_SIZE && title!=0 && blob_size(title)==0 ){
    BLOB_APPEND_BLOB(title, text);
    return;
  }
  html_text_to_id(text, &bId);
  INTER_BLOCK(ob);
  if(bId.nUsed>0){
    blob_appendf(ob, "<h%d id=\"%b\">", level, &bId);
  }else{
    blob_appendf(ob, "<h%d>", level);
  }
  BLOB_APPEND_BLOB(ob, text);
  blob_appendf(ob, "</h%d>", level);
  blob_reset(&bId);
}

static void html_hrule(struct Blob *ob, void *opaque){
  INTER_BLOCK(ob);
  BLOB_APPEND_LITERAL(ob, "<hr />\n");
}