Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/tidyenum.h
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,7 @@ typedef enum
TidyJoinClasses, /**< Join multiple class attributes */
TidyJoinStyles, /**< Join multiple style attributes */
TidyKeepFileTimes, /**< If yes last modied time is preserved */
TidyKeepTabs, /**< If yes keep input source tabs */
TidyLiteralAttribs, /**< If true attributes may use newlines */
TidyLogicalEmphasis, /**< Replace i by em and b by strong */
TidyLowerLiterals, /**< Folds known attribute values to lower case */
Expand Down
1 change: 1 addition & 0 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ static const TidyOptionImpl option_defs[] =
{ TidyJoinClasses, MX, "join-classes", BL, no, ParsePickList, &boolPicks },
{ TidyJoinStyles, MX, "join-styles", BL, yes, 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 },
{ TidyLogicalEmphasis, MC, "logical-emphasis", BL, no, ParsePickList, &boolPicks },
{ TidyLowerLiterals, MR, "lower-literals", BL, yes, ParsePickList, &boolPicks },
Expand Down
21 changes: 21 additions & 0 deletions src/language_en.h
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,27 @@ static languageDefinition language_en = { whichPluralForm_en, {
"<br/>"
"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,
"With the default <var>no</var> Tidy will replace all source tabs, with spaces, "
"controlled by the option <code>tab-size</code>, and the current line offset. "
"Of course, except in the special blocks/elements enumerated below, this will later "
"be reduced to just one space. "
"<br/>"
"If set <var>yes</var> this option specifies Tidy should keep certain tabs "
"found in the source, but only "
"in preformatted blocks like <code>&lt;pre&gt;</code>, and other CDATA elements like "
"<code>&lt;script&gt;</code>, <code>&lt;style&gt;<code>, and other pseudo elements like "
"<code>&lt;?php ... ?&gt;</code>. As always, all other tabs, or sequences of tabs, in "
"the source will continue to be replaced with a space. "
},
{/* Important notes for translators:
- Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
<br/>.
Expand Down
9 changes: 9 additions & 0 deletions src/lexer.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ static tmbstr get_text_string(Lexer* lexer, Node *node)
if (c == '\n') {
buffer[i++] = '\\';
buffer[i++] = 'n';
} else if (c == '\t') {
buffer[i++] = '\\';
buffer[i++] = 't';
} else if ( c == ' ' ) {
if (!insp)
buffer[i++] = c;
Expand All @@ -84,6 +87,9 @@ static tmbstr get_text_string(Lexer* lexer, Node *node)
if (c == '\n') {
buffer[i++] = '\\';
buffer[i++] = 'n';
} else if (c == '\t') {
buffer[i++] = '\\';
buffer[i++] = 't';
} else if ( c == ' ' ) {
if (!insp)
buffer[i++] = c;
Expand Down Expand Up @@ -116,6 +122,9 @@ static tmbstr get_text_string(Lexer* lexer, Node *node)
if (c == '\n') {
buffer[i++] = '\\';
buffer[i++] = 'n';
} else if (c == '\t') {
buffer[i++] = '\\';
buffer[i++] = 't';
} else if ( c == ' ' ) {
if (!insp)
buffer[i++] = c;
Expand Down
13 changes: 8 additions & 5 deletions src/streamio.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ static void RestoreLastPos( StreamIn *in )
uint TY_(ReadChar)( StreamIn *in )
{
uint c = EndOfStream;
uint tabsize = cfg( in->doc, TidyTabSize );

if ( in->pushed )
return PopChar( in );
Expand Down Expand Up @@ -269,11 +268,15 @@ uint TY_(ReadChar)( StreamIn *in )

if (c == '\t')
{
in->tabs = tabsize > 0 ?
tabsize - ((in->curcol - 1) % tabsize) - 1
: 0;
Bool keeptabs = cfg( in->doc, TidyKeepTabs );
in->curcol++;
c = ' ';
if (!keeptabs) {
uint tabsize = cfg(in->doc, TidyTabSize);
in->tabs = tabsize > 0 ?
tabsize - ((in->curcol - 1) % tabsize) - 1
: 0;
c = ' ';
}
break;
}

Expand Down