@@ -453,6 +453,7 @@ private void BeforeAttribute()
453
453
// http://dev.w3.org/html5/spec/tokenization.html#attribute-name-state
454
454
// Read the 'name' (i.e. read until the '=' or whitespace/newline)
455
455
var name = Enumerable . Empty < HtmlSymbol > ( ) ;
456
+ var whitespaceAfterAttributeName = Enumerable . Empty < HtmlSymbol > ( ) ;
456
457
if ( At ( HtmlSymbolType . Text ) )
457
458
{
458
459
name = ReadWhile ( sym =>
@@ -462,6 +463,11 @@ private void BeforeAttribute()
462
463
sym . Type != HtmlSymbolType . CloseAngle &&
463
464
sym . Type != HtmlSymbolType . OpenAngle &&
464
465
( sym . Type != HtmlSymbolType . ForwardSlash || ! NextIs ( HtmlSymbolType . CloseAngle ) ) ) ;
466
+
467
+ // capture whitespace after attribute name (if any)
468
+ whitespaceAfterAttributeName = ReadWhile (
469
+ sym => sym . Type == HtmlSymbolType . WhiteSpace ||
470
+ sym . Type == HtmlSymbolType . NewLine ) ;
465
471
}
466
472
else
467
473
{
@@ -484,6 +490,7 @@ private void BeforeAttribute()
484
490
{
485
491
Accept ( whitespace ) ;
486
492
Accept ( name ) ;
493
+ Accept ( whitespaceAfterAttributeName ) ;
487
494
Output ( SpanKind . Markup ) ;
488
495
}
489
496
@@ -497,11 +504,14 @@ private void BeforeAttribute()
497
504
// Start a new markup block for the attribute
498
505
using ( Context . StartBlock ( BlockType . Markup ) )
499
506
{
500
- AttributePrefix ( whitespace , name ) ;
507
+ AttributePrefix ( whitespace , name , whitespaceAfterAttributeName ) ;
501
508
}
502
509
}
503
510
504
- private void AttributePrefix ( IEnumerable < HtmlSymbol > whitespace , IEnumerable < HtmlSymbol > nameSymbols )
511
+ private void AttributePrefix (
512
+ IEnumerable < HtmlSymbol > whitespace ,
513
+ IEnumerable < HtmlSymbol > nameSymbols ,
514
+ IEnumerable < HtmlSymbol > whitespaceAfterAttributeName )
505
515
{
506
516
// First, determine if this is a 'data-' attribute (since those can't use conditional attributes)
507
517
var name = nameSymbols . GetContent ( Span . Start ) ;
@@ -510,8 +520,13 @@ private void AttributePrefix(IEnumerable<HtmlSymbol> whitespace, IEnumerable<Htm
510
520
// Accept the whitespace and name
511
521
Accept ( whitespace ) ;
512
522
Accept ( nameSymbols ) ;
523
+ Accept ( whitespaceAfterAttributeName ) ;
513
524
Assert ( HtmlSymbolType . Equals ) ; // We should be at "="
514
525
AcceptAndMoveNext ( ) ;
526
+
527
+ // Accept the whitespace after Equals
528
+ AcceptWhile ( sym => sym . Type == HtmlSymbolType . WhiteSpace || sym . Type == HtmlSymbolType . NewLine ) ;
529
+
515
530
var quote = HtmlSymbolType . Unknown ;
516
531
if ( At ( HtmlSymbolType . SingleQuote ) || At ( HtmlSymbolType . DoubleQuote ) )
517
532
{
0 commit comments