diff --git a/src/renderer/mixins/video/ass/subtitles.js b/src/renderer/mixins/video/ass/subtitles.js
index abedac7..60996a2 100644
--- a/src/renderer/mixins/video/ass/subtitles.js
+++ b/src/renderer/mixins/video/ass/subtitles.js
@@ -49,7 +49,7 @@ export default function (subtitle, styles, info) {
// We handle newline "manually". Hence, there is a need for
// a masterId as to know which cues are initially the same.
result.masterId = `${result.start}-${result.end}-${result.line}-${result.position}-${result.text}`
- result.text = result.text.replace(/\\N/g, '
')
+ // result.text = result.text.replace(/\\N/g, '
')
// Style might ask for a rotation, this needs to be set as a key
// for the cue. It seems the rotation axis is inversed too.
diff --git a/src/renderer/mixins/video/ass/tags.js b/src/renderer/mixins/video/ass/tags.js
index a103e55..5390112 100644
--- a/src/renderer/mixins/video/ass/tags.js
+++ b/src/renderer/mixins/video/ass/tags.js
@@ -20,7 +20,7 @@ const re = {
to: ''
},
end: {
- from: /\\i0?/g,
+ from: /\\i0/g,
to: ''
}
},
@@ -91,22 +91,6 @@ const handleNewline = (string) => {
return string.replace(re.newline, '
')
}
-const handleCommon = (type, string) => {
- // Handles bold, italic and underline
- const re_ = re[type]
- let tag = null
-
- if (re_.start.from.test(string)) {
- return re_.start.to
- }
-
- if (re_.end.from.test(string)) {
- return re_.end.to
- }
-
- return tag
-}
-
const handleFontSize = (string, info) => {
const fontType = re.font.size.test(string) && string.match(re.font.size)[0]
@@ -344,6 +328,7 @@ const getEnclosedTags = (string) => {
const handleEnclosedTags = (enclosedTags, cue, style, info) => {
const cueStyle = {}
+ let addedLength = 0
return enclosedTags.map(({ tags, index }, k) => {
// Removing unsupported tags
@@ -352,17 +337,19 @@ const handleEnclosedTags = (enclosedTags, cue, style, info) => {
// Handling common tags
const types = ['bold', 'italic', 'underline', 'strike']
types.forEach((type) => {
- const tag = handleCommon(type, string)
+ const _re = re[type]
+ const isStart = string.match(_re.start.from)
+ const isEnd = string.match(_re.end.from)
- if (!tag) return
+ if (!isStart && !isEnd) return
- const l = tag.length
+ let tag = isStart
+ ? _re.start.to
+ : _re.end.to
+ index += addedLength
cue.text = cue.text.slice(0, index) + tag + cue.text.slice(index)
-
- if (k !== enclosedTags.length - 1) {
- enclosedTags[k + 1].index += l
- }
+ addedLength += tag.length - string.length
})
// Font
@@ -415,7 +402,5 @@ export default function (cue, style, info) {
}
})
- console.log(cue.text)
-
return cue
}