Branch: Tag:

2019-01-21

2019-01-21 13:44:58 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Tools.Standalone.autodoc_to_html: Improved rendering of <ol> and <ul>.

The renderers for <ol> and <ul> now share code.

The <ol> renderer now survives without <text>-nodes.

Improved rendering of <ol> and <ul> when both <li>-nodes with
name attributes and <text>-nodes are present.

815:    break;       case "ul": -  ret->add( "<ul>\n" ); +  case "ol": +  ret->add( "<", name, ">\n" );    foreach(c->get_elements("group"), Node c) { -  +  int got_item; +  foreach(c->get_elements, Node e) { +  switch(e->get_any_name()) { +  case "item": +  if (got_item) { +  ret->add("</li>"); +  }    ret->add("<li>"); -  array(Node) d = c->get_elements("item"); -  if(sizeof(d->get_attributes()->name-({0}))) { -  ret->add("<b>"); -  ret->add( String.implode_nicely(d->get_attributes()->name-({0})) ); -  ret->add("</b>"); +  string title = e->get_attributes()->name; +  if (title) { +  ret->add("<b>", title, "</b>");    } -  Node e = c->get_first_element("text"); -  if(e) +  got_item = 1; +  break; +  case "text": +  if (!got_item) { +  ret->add("<li>"); +  }    parse_text(e, ret);    ret->add("</li>"); -  } -  ret->add("</ul>"); +  got_item = 0;    break; -  -  case "ol": -  ret->add("<ol>\n"); -  foreach(c->get_elements("group"), Node c) { -  ret->add("<li>"); -  parse_text(c->get_first_element("text"), ret); +  default: +  // Ignored. +  break; +  } +  } +  if (got_item) {    ret->add("</li>"); -  +  got_item = 0;    } -  ret->add("</ol>"); +  } +  ret->add("</", name, ">");    break;       case "source-position":