Software /
code /
prosody
Comparison
util/stanza.lua @ 11960:12a3c05aa12d
util.stanza: Adjust pretty printing for symmetry
Self-closing <tags/> and <?processing instructions?> had some
asymmetries in applied colors.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 29 Nov 2021 02:13:45 +0100 |
parent | 11786:39164ea2ab9e |
child | 12138:644ca3583837 |
comparison
equal
deleted
inserted
replaced
11959:814b750aa2d0 | 11960:12a3c05aa12d |
---|---|
524 function pretty(s) | 524 function pretty(s) |
525 -- Tag soup color | 525 -- Tag soup color |
526 -- Outer gsub call takes each <tag>, applies colour to the brackets, the | 526 -- Outer gsub call takes each <tag>, applies colour to the brackets, the |
527 -- tag name, then applies one inner gsub call to colour the attributes and | 527 -- tag name, then applies one inner gsub call to colour the attributes and |
528 -- another for any text content. | 528 -- another for any text content. |
529 return (s:gsub("(</?)([^ >]*)(.-)([?/]?>)([^<]*)", function(opening_bracket, tag_name, attrs, closing_bracket, content) | 529 return (s:gsub("(<[?/]?)([^ >/?]*)(.-)([?/]?>)([^<]*)", function(opening_bracket, tag_name, attrs, closing_bracket, content) |
530 return getstring(blue1, opening_bracket)..getstring(blue2, tag_name).. | 530 return getstring(blue1, opening_bracket)..getstring(blue2, tag_name).. |
531 attrs:gsub("([^=]+)(=)([\"'])(.-)([\"'])", attr_replace) .. | 531 attrs:gsub("([^=]+)(=)([\"'])(.-)([\"'])", attr_replace) .. |
532 getstring(blue1, closing_bracket) .. | 532 getstring(blue1, closing_bracket) .. |
533 content:gsub("(&#?)(%w+)(;)", text_replace); | 533 content:gsub("(&#?)(%w+)(;)", text_replace); |
534 end, 100)); | 534 end, 100)); |