Skip to content

Commit

Permalink
Error for <dfn/code/span lt> and <a> sans href
Browse files Browse the repository at this point in the history
This helps catch mistakes now and makes it obvious you need to
update wattsi when we switch to `<a lt>` for cross-references.
  • Loading branch information
zcorpan authored and sideshowbarker committed Dec 24, 2015
1 parent 4d114d9 commit ce64b64
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/wattsi.pas
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<ref> should have a popup of the <dd> when hovered
use <a [data-x]> instead of <span [data-x]>
use <a [lt]> instead of <span [data-x]>
****************************)

Expand Down Expand Up @@ -60,6 +60,8 @@
kUndefinedAttribute = 'undefined';
kSplitFilenameAttribute = 'split-filename';
kSplitFilenameTargetAttribute = 'split-filename-target';
kLTAttribute = 'lt';
kHrefAttribute = 'href';
kNonNormative = 'This section is non-normative.';
kEllipsis = #$22F0;
Months: array[1..12] of UTF8String = ('January', 'February', 'March', 'April',
Expand Down Expand Up @@ -654,6 +656,8 @@ TCrossReferences = record
else
if (Element.IsIdentity(nsHTML, eDFN)) then
begin
if (Element.HasAttribute(kLTAttribute)) then
Fail('<dfn> with lt="" found, use data-x="" instead; dfn is ' + Describe(Element));
CrossReferenceName := GetTopicIdentifier(Element);
if (Assigned(InDFN)) then
Fail('Nested <dfn>: ' + Describe(Element));
Expand Down Expand Up @@ -691,17 +695,26 @@ TCrossReferences = record
else
if (Element.IsIdentity(nsHTML, eCode) and (not Assigned(InDFN))) then
begin
if (Element.HasAttribute(kLTAttribute)) then
Fail('<code> with lt="" found, use data-x="" instead; code is ' + Describe(Element));
SaveCrossReference(Element);
end
else
if (Element.IsIdentity(nsHTML, eSpan)) then
begin
if (Element.HasAttribute(kLTAttribute)) then
Fail('<span> with lt="" found, use data-x="" instead; span is ' + Describe(Element));
if (Assigned(InDFN)) then
Fail('<span> inside <dfn>; span is ' + Describe(Element))
else
SaveCrossReference(Element);
end
else
if (Element.isIdentity(nsHTML, eA) and (not Element.HasAttribute(kHrefAttribute))) then
begin
Fail('<a> without href found: ' + Describe(Element));
end
else
if (Element.IsIdentity(nsHTML, eI) and (not Assigned(InDFN)) and (Element.HasAttribute(kCrossRefAttribute))) then
begin
if (Element.GetAttribute(kCrossRefAttribute).IsEmpty) then
Expand Down

0 comments on commit ce64b64

Please sign in to comment.