mirror of https://github.com/odrling/Aegisub
Parse unclosed override blocks as plain text as VSFilter does
This commit is contained in:
parent
a4311b50f7
commit
bdf7a0ca83
|
@ -209,20 +209,19 @@ std::vector<AssDialogueBlock*> AssDialogue::ParseTags() const {
|
|||
for (size_t len = Text.size(), cur = 0; cur < len; ) {
|
||||
// Overrides block
|
||||
if (Text[cur] == '{') {
|
||||
size_t end = Text.find('}', cur);
|
||||
|
||||
// VSFilter requires that override blocks be closed, while libass
|
||||
// does not. We match VSFilter here.
|
||||
if (end == wxString::npos)
|
||||
goto plain;
|
||||
|
||||
++cur;
|
||||
// Get contents of block
|
||||
wxString work;
|
||||
size_t end = Text.find("}", cur);
|
||||
if (end == wxString::npos) {
|
||||
work = Text.substr(cur);
|
||||
cur = len;
|
||||
}
|
||||
else {
|
||||
work = Text.substr(cur, end - cur);
|
||||
wxString work = Text.substr(cur, end - cur);
|
||||
cur = end + 1;
|
||||
}
|
||||
|
||||
if (work.size() && work.Find("\\") == wxNOT_FOUND) {
|
||||
if (work.size() && work.find('\\') == wxString::npos) {
|
||||
//We've found an override block with no backslashes
|
||||
//We're going to assume it's a comment and not consider it an override block
|
||||
//Currently we'll treat this as a plain text block, but feel free to create a new class
|
||||
|
@ -236,16 +235,18 @@ std::vector<AssDialogueBlock*> AssDialogue::ParseTags() const {
|
|||
|
||||
// Look for \p in block
|
||||
for (auto tag : block->Tags) {
|
||||
if (tag->Name == "\\p") {
|
||||
if (tag->Name == "\\p")
|
||||
drawingLevel = tag->Params[0]->Get<int>(0);
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Plain-text/drawing block
|
||||
else {
|
||||
plain:
|
||||
wxString work;
|
||||
size_t end = Text.find("{",cur);
|
||||
size_t end = Text.find('{', cur + 1);
|
||||
if (end == wxString::npos) {
|
||||
work = Text.substr(cur);
|
||||
cur = len;
|
||||
|
@ -255,16 +256,11 @@ std::vector<AssDialogueBlock*> AssDialogue::ParseTags() const {
|
|||
cur = end;
|
||||
}
|
||||
|
||||
// Plain-text
|
||||
if (drawingLevel == 0) {
|
||||
if (drawingLevel == 0)
|
||||
Blocks.push_back(new AssDialogueBlockPlain(work));
|
||||
}
|
||||
// Drawing
|
||||
else {
|
||||
else
|
||||
Blocks.push_back(new AssDialogueBlockDrawing(work, drawingLevel));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Blocks;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue