Skip to content

Commit

Permalink
Handle 3+ ' in a more complete way.
Browse files Browse the repository at this point in the history
  • Loading branch information
tabatkins committed Jul 22, 2024
1 parent c8e463a commit 8bee7fc
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
24 changes: 13 additions & 11 deletions bikeshed/h/parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,23 +202,25 @@ def parseNode(
if els is not None:
return Result(els, i)
if s.config.css and not inOpaque:
if first3 == r"\''":
node = RawText.fromStream(s, start, start + 3, "''")
return Result(node, start + 3)
elif first2 == r"\'":
node = RawText.fromStream(s, start, start + 2, "'")
return Result(node, start + 2)
if first2 == r"\'":
i = start + 2
while s[i] == "'":
i += 1
node = RawText.fromStream(s, start, i, s[start + 1 : i])
return Result(node, i)
elif first3 == "'''":
i = start + 3
while s[i] == "'":
i += 1
m.die(
"Saw ''' (or more). This is probably a typo intended to be a double apostrophe, starting a CSS maybe autolink; if not, please escape some of the apostrophes.",
f"Saw {s[start:i]}. This is probably a typo intended to be a double apostrophe, starting a CSS maybe autolink; if not, please escape some of the apostrophes.",
lineNum=s.loc(start),
)
node = RawText.fromStream(s, start, start + 3)
return Result(node, start + 3)
elif first2 == "''" and s[start - 1] not in ("'", "="):
node = RawText.fromStream(s, start, i)
return Result(node, i)
elif first2 == "''" and s[start - 1] != "=":
# Temporary check to remove some error cases -
# some weird HTML cases with an empty attr can trigger,
# or there's some bizarre '''' in CSS2.
maybeRes = parseCSSMaybe(s, start)
if maybeRes.valid:
return maybeRes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
LINE 74:6: Saw ''' (or more). This is probably a typo intended to be a double apostrophe, starting a CSS maybe autolink; if not, please escape some of the apostrophes.
LINE 74:24: Saw ''' (or more). This is probably a typo intended to be a double apostrophe, starting a CSS maybe autolink; if not, please escape some of the apostrophes.
LINE 74:6: Saw '''. This is probably a typo intended to be a double apostrophe, starting a CSS maybe autolink; if not, please escape some of the apostrophes.
LINE 74:24: Saw '''. This is probably a typo intended to be a double apostrophe, starting a CSS maybe autolink; if not, please escape some of the apostrophes.
LINE 226: The var 'keyArg' (in algorithm 'to register a custom highlight') is only used once.
If this is not a typo, please add an ignore='' attribute to the <var>.
LINE 227: The var 'valueArg' (in algorithm 'to register a custom highlight') is only used once.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
LINE 1254:35: Attribute style appears twice in <td>.
LINE 1574:30: Saw ''' (or more). This is probably a typo intended to be a double apostrophe, starting a CSS maybe autolink; if not, please escape some of the apostrophes.
LINE 1574:30: Saw '''. This is probably a typo intended to be a double apostrophe, starting a CSS maybe autolink; if not, please escape some of the apostrophes.
LINE 1575:28: ''...'' autolink opened at 1575:28 wasn't closed within 3 lines. You might have forgotten to close it; if not, switch to the HTML syntax to spread your link across that many lines.
LINE 2468: Saw an end tag </ol>, but there's no open element corresponding to it.
LINT: Your document appears to use tabs to indent, but line 283 starts with spaces.
Expand Down
6 changes: 3 additions & 3 deletions tests/github/w3c/csswg-drafts/css2/Overview.console.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
LINE 2196:30: Saw ''' (or more). This is probably a typo intended to be a double apostrophe, starting a CSS maybe autolink; if not, please escape some of the apostrophes.
LINE 2217:30: Saw ''' (or more). This is probably a typo intended to be a double apostrophe, starting a CSS maybe autolink; if not, please escape some of the apostrophes.
LINE 2196:30: Saw ''''. This is probably a typo intended to be a double apostrophe, starting a CSS maybe autolink; if not, please escape some of the apostrophes.
LINE 2217:30: Saw ''''. This is probably a typo intended to be a double apostrophe, starting a CSS maybe autolink; if not, please escape some of the apostrophes.
LINE 2654: Saw an end tag </p>, but there were unclosed elements remaining before the nearest matching start tag (on line 2646).
Open tags: <p> at 2646:1, ''...'' at 2653:40
LINE 2653:40: ''...'' autolink opened at 2653:40 wasn't closed within 3 lines. You might have forgotten to close it; if not, switch to the HTML syntax to spread your link across that many lines.
Expand All @@ -10,7 +10,7 @@ Open tags: <p> at 2655:1, ''...'' at 2657:74
LINE 2657:74: ''...'' autolink opened at 2657:74 wasn't closed within 3 lines. You might have forgotten to close it; if not, switch to the HTML syntax to spread your link across that many lines.
LINE 2661:19: ''...'' shorthand (opened on 2657:74) was closed, but there were still open elements inside of it.
Open tags: <p> at 2655:1, ''...'' at 2657:74, <p> at 2660:1
LINE 10583:21: Saw ''' (or more). This is probably a typo intended to be a double apostrophe, starting a CSS maybe autolink; if not, please escape some of the apostrophes.
LINE 10583:21: Saw ''''. This is probably a typo intended to be a double apostrophe, starting a CSS maybe autolink; if not, please escape some of the apostrophes.
LINE 15173:17: The autolink ''<<border-style>>/none'' is using an HTML escape (or <<) in its for value; you probably don't want to escape things there.
(See https://speced.github.io/bikeshed/#autolink-limits )
LINT: Your document appears to use spaces to indent, but line 559 starts with tabs.
Expand Down

0 comments on commit 8bee7fc

Please sign in to comment.