| Paste number 56955: | clumsy method |
| Pasted by: | |Agent |
| 4 months, 2 weeks ago | |
| #dylan | Context in IRC logs | |
| Paste contents: |
| /// Synopsis: Returns the intermediate elements that make up a quote. /// /// Discussion: Style changes affect the entire render. Link and monospace /// affect everything inside typographical quotes. The actual link tag is /// innermost so its text can be replaced easily by a topic title or an /// <api-name> or <parameter-name> object (perhaps surrounded by an <xref>). /// /// From innermost to outermost, the quoted text is wrapped in: /// link-placeholder, term, code, typographical quotes, bib, b, i, u, term formatting, em /// define method quote-elements (owner :: <interm-object>, quote :: <quote-token>) => (outer-quote-elem :: <interm-object>) let specs = check-quote-specifiers(quote); let interior = if (member?(#"sic", specs)) concatenate(quote.open-quote, quote.quoted-content, quote-close-quote) else quote.quoted-content end if; let link-target = if (instance?(specs.last, <string>)) specs.last else interior end; let last-owned = #f; if (member?(#"qv", specs) | member?(#"toc", specs)) let link = make(<link-placeholder>) link.text := interior; link.target := link-target; interior := link; last-owned := link; end if; if (member?(#"term", specs)) let term = make(<term>); term.text := interior interior := term; if (last-owned) last-owned.element-owner := term end; last-owned := term; end if; if (member?(#"code", specs)) let code = make(<code-phrase>); code.text := interior; if (last-owned) last-owned.element-owner := code end; last-owned := code; end if; if (member?(#"q", specs)) interior := vector("‘", interior, "’"); end if; if (member?(#"qq", specs)) interior := vector("“", interior, "”"); end if; if (member?(#"bib", specs)) let cite = make(<cite>); cite.text := interior; interior := cite; if (last-owned) last-owned.element-owner := cite end; last-owned := cite; end if; if (member?(#"b", specs)) let bold = make(<bold>); bold.text := interior; interior := bold; if (last-owned) last-owned.element-owner := bold end; last-owned := bold; end if; if (member?(#"i", specs)) let ital = make(<italic>); ital.text := interior; interior := ital; if (last-owned) last-owned.element-owner := ital end; last-owned := ital; end if; if (member?(#"u", specs)) let ul = make(<underline>); ul.text := interior; interior := ul; if (last-owned) last-owned.element-owner := ul end; last-owned := ul; end if; if (member?(#"term", specs)) let style = make(<term-style>); style.text := interior; interior := style; if (last-owned) last-owned.element-owner := style end; last-owned := style; end if; if (member?(#"em", specs)) let em = make(<emphasis>); em.text := interior; interior := em; if (last-owned) last-owned.element-owner := em end; last-owned := em; end if; if (last-owned) last-owned.element-owner := owner end; last-owned end method; |
Annotations for this paste:
| Annotation number 1: | tips for declumsifying |
| Pasted by: | gabor |
| 4 months, 2 weeks ago | |
| Context in IRC logs | |
| Paste contents: |
| gabor: |Agent: you could use a "select ( ... by predicate) ... end" to get rid of the ugly "if"s gabor: and "let last-owned = select()" try not to use ":=" |