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:
parent
116b9b0ceb
commit
01fa1513f4
|
@ -161,7 +161,7 @@
|
|||
# instruction.
|
||||
#
|
||||
|
||||
proc_ins_start = '<?' identifier;
|
||||
proc_ins_start = '<?' identifier (':' identifier)?;
|
||||
proc_ins_end = '?>';
|
||||
|
||||
# Everything except "?" OR a single "?"
|
||||
|
|
|
@ -70,6 +70,14 @@ describe Oga::XML::Lexer do
|
|||
]
|
||||
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
|
||||
it 'lexes an instruction with a newline after the name' do
|
||||
lex_stringio("<?foo\nbar?>").should == [
|
||||
|
|
|
@ -32,4 +32,11 @@ describe Oga::XML::Parser do
|
|||
@node.text.should == ' bar '
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue