Issue #403 - New 'keep-tabs' option to address this.

This commit is contained in:
Geoff McLane 2017-11-03 19:16:17 +01:00
parent 4b5c86ee47
commit 2aeb2eeb7a
4 changed files with 21 additions and 5 deletions

View file

@ -604,6 +604,7 @@ typedef enum
TidyJoinClasses, /**< Join multiple class attributes */ TidyJoinClasses, /**< Join multiple class attributes */
TidyJoinStyles, /**< Join multiple style attributes */ TidyJoinStyles, /**< Join multiple style attributes */
TidyKeepFileTimes, /**< If yes last modied time is preserved */ TidyKeepFileTimes, /**< If yes last modied time is preserved */
TidyKeepTabs, /**< If yes keep input source tabs */
TidyLiteralAttribs, /**< If true attributes may use newlines */ TidyLiteralAttribs, /**< If true attributes may use newlines */
TidyLogicalEmphasis, /**< Replace i by em and b by strong */ TidyLogicalEmphasis, /**< Replace i by em and b by strong */
TidyLowerLiterals, /**< Folds known attribute values to lower case */ TidyLowerLiterals, /**< Folds known attribute values to lower case */

View file

@ -214,6 +214,7 @@ static const TidyOptionImpl option_defs[] =
{ TidyJoinClasses, MX, "join-classes", BL, no, ParsePickList, &boolPicks }, { TidyJoinClasses, MX, "join-classes", BL, no, ParsePickList, &boolPicks },
{ TidyJoinStyles, MX, "join-styles", BL, yes, ParsePickList, &boolPicks }, { TidyJoinStyles, MX, "join-styles", BL, yes, ParsePickList, &boolPicks },
{ TidyKeepFileTimes, IO, "keep-time", BL, no, ParsePickList, &boolPicks }, { TidyKeepFileTimes, IO, "keep-time", BL, no, ParsePickList, &boolPicks },
{ TidyKeepTabs, PP, "keep-tabs", BL, no, ParsePickList, &boolPicks }, /* 20171103 - Issue #403 */
{ TidyLiteralAttribs, MR, "literal-attributes", BL, no, ParsePickList, &boolPicks }, { TidyLiteralAttribs, MR, "literal-attributes", BL, no, ParsePickList, &boolPicks },
{ TidyLogicalEmphasis, MC, "logical-emphasis", BL, no, ParsePickList, &boolPicks }, { TidyLogicalEmphasis, MC, "logical-emphasis", BL, no, ParsePickList, &boolPicks },
{ TidyLowerLiterals, MR, "lower-literals", BL, yes, ParsePickList, &boolPicks }, { TidyLowerLiterals, MR, "lower-literals", BL, yes, ParsePickList, &boolPicks },

View file

@ -699,6 +699,17 @@ static languageDefinition language_en = { whichPluralForm_en, {
"<br/>" "<br/>"
"Note this feature is not supported on some platforms. " "Note this feature is not supported on some platforms. "
}, },
{/* Important notes for translators:
- Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
<br/>.
- Entities, tags, attributes, etc., should be enclosed in <code></code>.
- Option values should be enclosed in <var></var>.
- It's very important that <br/> be self-closing!
- The strings "Tidy" and "HTML Tidy" are the program name and must not
be translated. */
TidyKeepTabs, 0,
"This option specifies if Tidy should keep tabs found in the source. "
},
{/* Important notes for translators: {/* Important notes for translators:
- Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
<br/>. <br/>.

View file

@ -239,7 +239,6 @@ static void RestoreLastPos( StreamIn *in )
uint TY_(ReadChar)( StreamIn *in ) uint TY_(ReadChar)( StreamIn *in )
{ {
uint c = EndOfStream; uint c = EndOfStream;
uint tabsize = cfg( in->doc, TidyTabSize );
if ( in->pushed ) if ( in->pushed )
return PopChar( in ); return PopChar( in );
@ -269,11 +268,15 @@ uint TY_(ReadChar)( StreamIn *in )
if (c == '\t') if (c == '\t')
{ {
in->tabs = tabsize > 0 ? Bool keeptabs = cfg( in->doc, TidyKeepTabs );
tabsize - ((in->curcol - 1) % tabsize) - 1
: 0;
in->curcol++; in->curcol++;
c = ' '; if (!keeptabs) {
uint tabsize = cfg(in->doc, TidyTabSize);
in->tabs = tabsize > 0 ?
tabsize - ((in->curcol - 1) % tabsize) - 1
: 0;
c = ' ';
}
break; break;
} }