Closed sphh closed 3 years ago
not sure why this change is needed... *
should subsume ?
so why make the regexp more restrictive?
Let me think. I did that 3½ months ago …
Ah, I remember (https://github.com/protz/LatexIt/issues/77#issue-733032602 and https://github.com/protz/LatexIt/issues/76): If I have a preamble like this:
%&latex
\documentclass{article}
\usepackage{utf8}
\usepackage[active,displaymath,textmath]{preview}
\pagestyle{empty}
…
(or any other with a comment before the preview
line) the old regex did not find the line with preview
in it, because [^%]*
became greedy and swallowed everything after the first %
, including the preview
line.
Possibly there are better ways, but it worked for me.
Ok, it's a little restrictive since it may now no longer accept something like \usepackage...
(two leading spaces). Let me know if you want to change the [^%]?
to :space:*
(or whatever the syntax is) or if you think this is fine as it is.
I see your point. This might work (not tested, because I am already on TB 78 …):
var re = /^\s*[^%]?\\usepackage\[(.*,\s*)?active(,.*)?\]{(.*,\s*)?preview(,.*)?}/m;
I really cannot remember anymore, why I had to do it that way. Wenn I tried it today with the old regex it worked without any problems.
I close this PR.
Find the
preview
package even if there is any comment before the line including it. (Closes #77 and #76)