yitzchak / dicy

A builder for LaTeX, knitr, literate Agda, literate Haskell and Pweave that automatically builds dependencies.
https://yitzchak.github.io/dicy/
MIT License
21 stars 2 forks source link

DiCy doesn't recognize LaTeX files if they include commands before the document class #142

Closed ngld closed 6 years ago

ngld commented 6 years ago

I have a LaTeX file which begins like this:

\PassOptionsToPackage{unicode=true}{hyperref} % options for packages loaded elsewhere
\PassOptionsToPackage{hyphens}{url}
\documentclass{article}

DiCy doesn't recognize it as a LaTeX file since the file type regex is too strict and dosen't allow any commands before \documentclass. Would it be possible to relax that regex?

As a workaround, I've moved the commands below \documentclass which fixes the problem but it would be nice if DiCy could support these files without changes.

yitzchak commented 6 years ago

I don't have a problem considering relaxing the regex, but is \PassOptionsToPackage actually required before \documentclass?

ngld commented 6 years ago

\PassOptionsToPackage doesn't have to appear before \documentclass. As I mentioned, moving it below \documentclass fixes the problem for me.

However, it was weird having DiCy complain that no rules were defined for my file even though it was a valid LaTeX file. After digging through the code, I found out that it didn't detect it as LaTeX due to the regex not matching.

yitzchak commented 6 years ago

Okay, I understand. I'll see what I can do about tweaking the regex.

Thanks again for the feedback!

yitzchak commented 5 years ago

@ngld Just released v0.14.0 with this fix. Thanks for pointing out this issue.