Lexing of processing instructions with namespaces

This adds lexing/parsing support for processing instructions that
contain namespace prefixes such as `<?foo:bar ?>`.
This commit is contained in:
Yorick Peterse 2016-09-17 14:49:23 +02:00
parent 116b9b0ceb
commit 01fa1513f4
No known key found for this signature in database
GPG Key ID: EDD30D2BEB691AC9
3 changed files with 16 additions and 1 deletions

View File

@ -161,7 +161,7 @@
# instruction. # instruction.
# #
proc_ins_start = '<?' identifier; proc_ins_start = '<?' identifier (':' identifier)?;
proc_ins_end = '?>'; proc_ins_end = '?>';
# Everything except "?" OR a single "?" # Everything except "?" OR a single "?"

View File

@ -70,6 +70,14 @@ describe Oga::XML::Lexer do
] ]
end end
it 'lexes an instruction with a namespace prefix' do
lex('<?foo:bar?>').should == [
[:T_PROC_INS_START, nil, 1],
[:T_PROC_INS_NAME, 'foo:bar', 1],
[:T_PROC_INS_END, nil, 1]
]
end
describe 'using an IO as input' do describe 'using an IO as input' do
it 'lexes an instruction with a newline after the name' do it 'lexes an instruction with a newline after the name' do
lex_stringio("<?foo\nbar?>").should == [ lex_stringio("<?foo\nbar?>").should == [

View File

@ -32,4 +32,11 @@ describe Oga::XML::Parser do
@node.text.should == ' bar ' @node.text.should == ' bar '
end end
end end
it 'parses a processing instruction with a namespace prefix' do
node = parse('<?foo:bar ?>').children[0]
node.should be_an_instance_of(Oga::XML::ProcessingInstruction)
node.name.should == 'foo:bar'
end
end end