From 2976696523599a4ee632e78e181b59ed00dd2202 Mon Sep 17 00:00:00 2001 From: eleith Date: Fri, 29 Mar 2013 04:24:14 -0700 Subject: [PATCH] only format if a tag comes back when peeking --- beautify-html.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/beautify-html.js b/beautify-html.js index 41ae79f0..ec5974b1 100644 --- a/beautify-html.js +++ b/beautify-html.js @@ -449,7 +449,14 @@ function style_html(html_source, options) { //at this point we have an tag; is its first child something we want to remain //unformatted? var next_tag = this.get_tag(true /* peek. */); - if (next_tag && this.Utils.in_array(next_tag, unformatted)){ + + // tets next_tag to see if it is just html tag (no external content) + var tag = (next_tag || "").match(/^\s*<\s*\/?([a-z]*)\s*[^>]*>\s*$/); + + // if next_tag comes back but is not an isolated tag, then + // let's treat the 'a' tag as having content + // and respect the unformatted option + if (!tag || this.Utils.in_array(tag, unformatted)){ return true; } else { return false;