diff --git a/include/tidyenum.h b/include/tidyenum.h index a125bce..1cef305 100644 --- a/include/tidyenum.h +++ b/include/tidyenum.h @@ -126,6 +126,7 @@ typedef enum TidyLogicalEmphasis, /**< Replace i by em and b by strong */ TidyDropPropAttrs, /**< Discard proprietary attributes */ TidyDropFontTags, /**< Discard presentation tags */ + TidyDropEmptyElems, /**< Discard empty elements */ TidyDropEmptyParas, /**< Discard empty p elements */ TidyFixComments, /**< Fix comments with adjacent hyphens */ TidyBreakBeforeBR, /**< Output newline before
or not? */ diff --git a/src/config.c b/src/config.c index 6eb8287..95c3394 100644 --- a/src/config.c +++ b/src/config.c @@ -251,6 +251,7 @@ static const TidyOptionImpl option_defs[] = { TidyLogicalEmphasis, MU, "logical-emphasis", BL, no, ParseBool, boolPicks }, { TidyDropPropAttrs, MU, "drop-proprietary-attributes", BL, no, ParseBool, boolPicks }, { TidyDropFontTags, MU, "drop-font-tags", BL, no, ParseBool, boolPicks }, + { TidyDropEmptyElems, MU, "drop-empty-elements", BL, yes, ParseBool, boolPicks }, { TidyDropEmptyParas, MU, "drop-empty-paras", BL, yes, ParseBool, boolPicks }, { TidyFixComments, MU, "fix-bad-comments", BL, yes, ParseBool, boolPicks }, { TidyBreakBeforeBR, PP, "break-before-br", BL, no, ParseBool, boolPicks }, diff --git a/src/localize.c b/src/localize.c index 9823f12..b47870a 100644 --- a/src/localize.c +++ b/src/localize.c @@ -425,6 +425,9 @@ static const TidyOptionDoc option_docs[] = "--numeric-entities yes. This option does not offer a " "validation of the document conformance. " }, + {TidyDropEmptyElems, + "This option specifies if Tidy should discard empty elements. " + }, {TidyDropEmptyParas, "This option specifies if Tidy should discard empty paragraphs. " }, diff --git a/src/parser.c b/src/parser.c index aad2d14..46d1728 100644 --- a/src/parser.c +++ b/src/parser.c @@ -240,6 +240,9 @@ void TY_(InsertNodeAfterElement)(Node *element, Node *node) static Bool CanPrune( TidyDocImpl* doc, Node *element ) { + if ( !cfgBool(doc, TidyDropEmptyElems) ) + return no; + if ( TY_(nodeIsText)(element) ) return yes;