+ position: { start: [0, 0], text:
}
+ - type: LiquidVariableOutput
+ whitespaceStart: ""
+ whitespaceEnd: ""
+ markupPosition: { start: [0, 7], text: " x " }
+ position: { start: [0, 5], text: "{{ x }}" }
+ markup:
+ type: LiquidVariable
+ rawSource: x
+ position: { start: [0, 8], text: "x " }
+ expression:
+ type: VariableLookup
+ name: x
+ position: { start: [0, 8], text: x }
+ lookups: []
+ lookupModes: []
+ filters: []
+ - type: TextNode
+ value:
+ position: { start: [0, 12], text:
}
+ - name: should return DocumentNode with empty children
+ source: ""
+ parse: [html, liquid]
+ ast:
+ type: Document
+ name: "#document"
+ position: { start: [0, 0], text: "" }
+ children: []
+ - name: should parse plain text as a single TextNode
+ source: hello world
+ parse: [html]
+ ast:
+ type: Document
+ name: "#document"
+ position: { start: [0, 0], text: hello world }
+ children:
+ - type: TextNode
+ value: hello world
+ position: { start: [0, 0], text: hello world }
+ - name: should preserve whitespace and newlines
+ source: |2
+ hello
+ world
+ parse: [html]
+ ast:
+ type: Document
+ name: "#document"
+ position:
+ start: [0, 0]
+ text: |2
+ hello
+ world
+ children:
+ - type: TextNode
+ value: |-
+ hello
+ world
+ position:
+ start: [0, 2]
+ text: |-
+ hello
+ world
+ - name: should work with whitespace-only source
+ source: " \ \n\t "
+ parse: [html]
+ ast:
+ type: Document
+ name: "#document"
+ position:
+ start: [0, 0]
+ text: " \ \n\t "
+ children: []
+ - name: should parse YAML frontmatter followed by text
+ source: |-
+ ---
+ key: value
+ ---
+ rest
+ parse: [html]
+ ast:
+ type: Document
+ name: "#document"
+ position:
+ start: [0, 0]
+ text: |-
+ ---
+ key: value
+ ---
+ rest
+ children:
+ - type: YAMLFrontmatter
+ body: |
+ key: value
+ position:
+ start: [0, 0]
+ text: |
+ ---
+ key: value
+ ---
+ - type: TextNode
+ value: rest
+ position: { start: [3, 0], text: rest }
+ - name: should parse YAML frontmatter without trailing text
+ source: |-
+ ---
+ key: value
+ ---
+ parse: [html]
+ ast:
+ type: Document
+ name: "#document"
+ position:
+ start: [0, 0]
+ text: |-
+ ---
+ key: value
+ ---
+ children:
+ - type: YAMLFrontmatter
+ body: |
+ key: value
+ position:
+ start: [0, 0]
+ text: |-
+ ---
+ key: value
+ ---
+ - name: should extract multi-line body correctly
+ source: |
+ ---
+ title: hello
+ author: world
+ ---
+ parse: [html]
+ ast:
+ type: Document
+ name: "#document"
+ position:
+ start: [0, 0]
+ text: |
+ ---
+ title: hello
+ author: world
+ ---
+ children:
+ - type: YAMLFrontmatter
+ body: |
+ title: hello
+ author: world
+ position:
+ start: [0, 0]
+ text: |
+ ---
+ title: hello
+ author: world
+ ---
+ - name: should handle YAML frontmatter + Liquid drop
+ source: |-
+ ---
+ k: v
+ ---
+ {{ x }}
+ parse: [html]
+ ast:
+ type: Document
+ name: "#document"
+ position:
+ start: [0, 0]
+ text: |-
+ ---
+ k: v
+ ---
+ {{ x }}
+ children:
+ - type: YAMLFrontmatter
+ body: |
+ k: v
+ position:
+ start: [0, 0]
+ text: |
+ ---
+ k: v
+ ---
+ - type: LiquidVariableOutput
+ whitespaceStart: ""
+ whitespaceEnd: ""
+ markupPosition: { start: [3, 2], text: " x " }
+ position: { start: [3, 0], text: "{{ x }}" }
+ markup:
+ type: LiquidVariable
+ rawSource: x
+ position: { start: [3, 3], text: "x " }
+ expression:
+ type: VariableLookup
+ name: x
+ position: { start: [3, 3], text: x }
+ lookups: []
+ lookupModes: []
+ filters: []
+ - name: 'should have correct structure for: "hello"'
+ source: hello
+ parse: [html]
+ ast:
+ type: Document
+ name: "#document"
+ position: { start: [0, 0], text: hello }
+ children:
+ - type: TextNode
+ value: hello
+ position: { start: [0, 0], text: hello }
+ - name: 'should have correct structure for: "--- k: v --- rest"'
+ source: |-
+ ---
+ k: v
+ ---
+ rest
+ parse: [html]
+ ast:
+ type: Document
+ name: "#document"
+ position:
+ start: [0, 0]
+ text: |-
+ ---
+ k: v
+ ---
+ rest
+ children:
+ - type: YAMLFrontmatter
+ body: |
+ k: v
+ position:
+ start: [0, 0]
+ text: |
+ ---
+ k: v
+ ---
+ - type: TextNode
+ value: rest
+ position: { start: [3, 0], text: rest }
+ - name: 'should have correct structure for: "
+ position: { start: [3, 0], text:
}
+ - type: LiquidVariableOutput
+ whitespaceStart: ""
+ whitespaceEnd: ""
+ markupPosition: { start: [3, 7], text: " x " }
+ position: { start: [3, 5], text: "{{ x }}" }
+ markup:
+ type: LiquidVariable
+ rawSource: x
+ position: { start: [3, 8], text: "x " }
+ expression:
+ type: VariableLookup
+ name: x
+ position: { start: [3, 8], text: x }
+ lookups: []
+ lookupModes: []
+ filters: []
+ - type: TextNode
+ value:
+ position: { start: [3, 12], text:
}
+ - name: should count positions in UTF-16 code units
+ source: 🙂 {{ x }}
+ parse: [html, liquid]
+ ast:
+ type: Document
+ name: "#document"
+ position: { start: [0, 0], text: "🙂 {{ x }}" }
+ children:
+ - type: TextNode
+ value: 🙂
+ position: { start: [0, 0], text: 🙂 }
+ - type: LiquidVariableOutput
+ whitespaceStart: ""
+ whitespaceEnd: ""
+ markupPosition: { start: [0, 5], text: " x " }
+ position: { start: [0, 3], text: "{{ x }}" }
+ markup:
+ type: LiquidVariable
+ rawSource: x
+ position: { start: [0, 6], text: "x " }
+ expression:
+ type: VariableLookup
+ name: x
+ position: { start: [0, 6], text: x }
+ lookups: []
+ lookupModes: []
+ filters: []
+ - name: should count error locations in UTF-16 code units
+ source: |-
+ 🙂
+ 🙂 {% if a %}
+ parse: [html]
+ error:
+ message: Attempting to end parsing before LiquidTag 'if' was closed
+ start: [1, 3]
+ text: "{% if a %"
diff --git a/specs/parser/html.yml b/specs/parser/html.yml
new file mode 100644
index 000000000..8e5047ca9
--- /dev/null
+++ b/specs/parser/html.yml
@@ -0,0 +1,4930 @@
+cases:
+ - name: should parse HTML attributes
+ source: