diff --git a/src/parser/html/PhutilHTMLParser.php b/src/parser/html/PhutilHTMLParser.php --- a/src/parser/html/PhutilHTMLParser.php +++ b/src/parser/html/PhutilHTMLParser.php @@ -30,9 +30,13 @@ continue; } - if (!$in_tag && ($c === '<')) { + // When we encounter a "<", we start a new tag whether we're already in + // a tag or not. We want to parse "1 < 2" as a single tag with + // the content "1 < 2". + + if ($c === '<') { $segments[] = array( - 'tag' => $in_tag, + 'tag' => false, 'pos' => $segment_pos, 'end' => $ii, ); diff --git a/src/parser/html/__tests__/data/tag-angle.txt b/src/parser/html/__tests__/data/tag-angle.txt new file mode 100644 --- /dev/null +++ b/src/parser/html/__tests__/data/tag-angle.txt @@ -0,0 +1,13 @@ +1 < 2 +~~~~~~~~~~ +[ + { + "tag": "math", + "attributes": {}, + "children": [ + { + "content": "1 < 2" + } + ] + } +]