package codeview import ( "regexp" "strings" ) // blockElements are the elements whose boxes are blocks: whitespace // between two tags where one of these is involved renders as nothing, // so a line break there moves no pixel. Everything else (a, span, // button, label, input, svg) is inline or inline-block, where a space // is a space a reader sees, and is broken only where one of the rules // in layout says the space cannot show. var blockElements = map[string]bool{ "address": true, "article": true, "aside": true, "blockquote": true, "details": true, "dialog": true, "dd": true, "div": true, "dl": true, "dt": true, "fieldset": true, "figcaption": true, "figure": true, "footer": true, "form": true, "h1": true, "h2": true, "h3": true, "h4": true, "h5": true, "h6": true, "header": true, "hgroup": true, "hr": true, "legend": true, "li": true, "main": true, "nav": true, "ol": true, "p": true, "pre": true, "search": true, "section": true, "summary": true, "table": true, "tbody": true, "td": true, "tfoot": true, "th": true, "thead": true, "tr": true, "ul": true, // Inside a select, which listElements covers: an option and a // group are drawn by the control, not laid out as text. "optgroup": true, "option": true, } // listElements hold a list the control draws (a select's options, a // datalist's suggestions), so nothing between their children renders // and each child can have a line. The element itself is inline-level: // a select sits in a sentence like a word, and the space after it // shows, so it is not a block and is never broken out of its line. var listElements = map[string]bool{"select": true, "datalist": true, "optgroup": true} // rawElements keep every byte inside them. A
or