You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-07-16 22:42:38 +02:00
lavc/htmlsubtitles: improve line breaks handling
This commit is contained in:
@ -165,7 +165,7 @@ int ff_htmlmarkup_to_ass(void *log_ctx, AVBPrint *dst, const char *in)
|
|||||||
#define LIKELY_A_TAG_CHAR(x) (((x) >= '0' && (x) <= '9') || \
|
#define LIKELY_A_TAG_CHAR(x) (((x) >= '0' && (x) <= '9') || \
|
||||||
((x) >= 'a' && (x) <= 'z') || \
|
((x) >= 'a' && (x) <= 'z') || \
|
||||||
((x) >= 'A' && (x) <= 'Z') || \
|
((x) >= 'A' && (x) <= 'Z') || \
|
||||||
(x) == '_')
|
(x) == '_' || (x) == '/')
|
||||||
for (i = 0; tagname[i]; i++) {
|
for (i = 0; tagname[i]; i++) {
|
||||||
if (!LIKELY_A_TAG_CHAR(tagname[i])) {
|
if (!LIKELY_A_TAG_CHAR(tagname[i])) {
|
||||||
likely_a_tag = 0;
|
likely_a_tag = 0;
|
||||||
@ -237,7 +237,8 @@ int ff_htmlmarkup_to_ass(void *log_ctx, AVBPrint *dst, const char *in)
|
|||||||
} else if (tagname[0] && !tagname[1] && strchr("bisu", av_tolower(tagname[0]))) {
|
} else if (tagname[0] && !tagname[1] && strchr("bisu", av_tolower(tagname[0]))) {
|
||||||
av_bprintf(dst, "{\\%c%d}", (char)av_tolower(tagname[0]), !tag_close);
|
av_bprintf(dst, "{\\%c%d}", (char)av_tolower(tagname[0]), !tag_close);
|
||||||
in += skip;
|
in += skip;
|
||||||
} else if (!av_strcasecmp(tagname, "br")) {
|
} else if (!av_strncasecmp(tagname, "br", 2) &&
|
||||||
|
(!tagname[2] || (tagname[2] == '/' && !tagname[3]))) {
|
||||||
av_bprintf(dst, "\\N");
|
av_bprintf(dst, "\\N");
|
||||||
in += skip;
|
in += skip;
|
||||||
} else if (likely_a_tag) {
|
} else if (likely_a_tag) {
|
||||||
|
@ -29,6 +29,8 @@ static const char * const test_cases[] = {
|
|||||||
"Foo <foo@bar.com>", // not a tag (not alnum)
|
"Foo <foo@bar.com>", // not a tag (not alnum)
|
||||||
|
|
||||||
"<b> foo <I> bar </B> bla </i>", // broken nesting
|
"<b> foo <I> bar </B> bla </i>", // broken nesting
|
||||||
|
|
||||||
|
"A<br>B<BR/>C<br / >D< Br >E<brk><brk/>", // misc line breaks
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
|
@ -5,3 +5,4 @@
|
|||||||
< font color=red >red</font> --> {\c&HFF&}red{\c}
|
< font color=red >red</font> --> {\c&HFF&}red{\c}
|
||||||
Foo <foo@bar.com> --> Foo <foo@bar.com>
|
Foo <foo@bar.com> --> Foo <foo@bar.com>
|
||||||
<b> foo <I> bar </B> bla </i> --> {\b1} foo {\i1} bar {\b0} bla {\i0}
|
<b> foo <I> bar </B> bla </i> --> {\b1} foo {\i1} bar {\b0} bla {\i0}
|
||||||
|
A<br>B<BR/>C<br / >D< Br >E<brk><brk/> --> A\NB\NC\ND\NE
|
||||||
|
Reference in New Issue
Block a user