mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Mw_parse.Prepro: Add more support for templates
This commit is contained in:
parent
1c0f9f4555
commit
086cdea9fb
@ -107,6 +107,10 @@ class Xomw_prepro_piece {
|
||||
this.line_start = line_start;
|
||||
parts.Add(new Xomw_prepro_part(Bry_.Empty));
|
||||
}
|
||||
public void Parts__renew() {
|
||||
parts.Clear();
|
||||
this.Add_part(Bry_.Empty);
|
||||
}
|
||||
public Xomw_prepro_part Get_current_part() {
|
||||
return (Xomw_prepro_part)parts.Get_at(parts.Len() - 1);
|
||||
}
|
||||
|
@ -691,7 +691,7 @@ public class Xomw_prepro_wkr { // THREAD.UNSAFE: caching for repeated calls
|
||||
|
||||
// Re-add the old stack element if it still has unmatched opening characters remaining
|
||||
if (matching_count < piece.count) {
|
||||
piece.parts.Clear(); // PORTED: piece.parts = [ new PPDPart ];
|
||||
piece.Parts__renew(); // PORTED: piece.parts = [ new PPDPart ];
|
||||
piece.count -= matching_count;
|
||||
|
||||
// do we still qualify for any callback with remaining count?
|
||||
|
@ -25,12 +25,33 @@ public class Xomw_prepro_wkr__tst {
|
||||
@Test public void Brack() {
|
||||
fxt.Test__parse("a[[b]]c", "<root>a[[b]]c</root>");
|
||||
}
|
||||
@Test public void Brack__one() { // COVERS: "Add literal brace(s)"
|
||||
fxt.Test__parse("a[b]c", "<root>a[b]c</root>");
|
||||
}
|
||||
@Test public void Brack__max() { // COVERS: "The specified maximum exists in the callback array, unless the caller"
|
||||
fxt.Test__parse("a[[[[[b]]]]]c", "<root>a[[[[[b]]]]]c</root>");
|
||||
}
|
||||
@Test public void Template() {
|
||||
fxt.Test__parse("a{{b}}c", "<root>a<template><title>b</title></template>c</root>");
|
||||
}
|
||||
@Test public void Template__args() {
|
||||
@Test public void Template__args__idx() {
|
||||
fxt.Test__parse("a{{b|c|d}}e", "<root>a<template><title>b</title><part><name index=\"1\" /><value>c</value></part><part><name index=\"2\" /><value>d</value></part></template>e</root>");
|
||||
}
|
||||
@Test public void Template__args__key() {
|
||||
fxt.Test__parse("a{{b|c=d}}e", "<root>a<template><title>b</title><part><name>c</name>=<value>d</value></part></template>e</root>");
|
||||
}
|
||||
@Test public void Template__line_start() { // COVERS: "The invocation is at the start of the line if lineStart is set in"
|
||||
fxt.Test__parse(String_.Concat_lines_nl_skip_last
|
||||
( "a"
|
||||
, "{{b}}"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<root>a"
|
||||
, "<template lineStart=\"1\"><title>b</title></template></root>"
|
||||
));
|
||||
}
|
||||
@Test public void Template__max() { // COVERS: "do we still qualify for any callback with remaining count?"
|
||||
fxt.Test__parse("a{{{{{b}}}}}c", "<root>a<template><title><tplarg><title>b</title></tplarg></title></template>c</root>");
|
||||
}
|
||||
@Test public void Tplarg() {
|
||||
fxt.Test__parse("a{{{b}}}c", "<root>a<tplarg><title>b</title></tplarg>c</root>");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user