1
$\begingroup$

I have french subscript file here: https://uploadfiles.io/iehon

If you download it an open it with Word, you can see that the math sections are but between $<i>$ and <\i>:

enter image description here

To import the file I use:

(*Importing*)
importSub = Import[FILEPATH, "Text", CharacterEncoding -> "UTF8"];
(*Deleting empty list elements*)
subtitle = DeleteCases[StringSplit[ToString[importSub], "\n"], ""];

In the end I want to convert the subtitles into Latex using TeXForm[...] but therefore, I need to convert the parts between $<i>$ and $<\i>$ to Mathematica Math Input.

Does anyone know how I can do that ?

$\endgroup$
1

1 Answer 1

1
$\begingroup$

Not a complete answer, but a bit long for a comment.

(* Positions of substrings delimited by <i>...</i> *)
delimited = StringPosition[importSub, Shortest["<i>" ~~ __ ~~ "</i>"]];

(* Extract 'math' substrings *)
math = StringTake[importSub, {First[#] + 3, Last[#] - 4}] & /@ delimited

I don't know anything about TeX so I cannot tell if mapping TeXForm on the math substrings generates the correct output or not. If it is correct, then the substrings in importSub can be replaced by the TeXForm. Deleting empty strings can be done after that.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.