-
-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subsection not being child of Section inspection #1492
Subsection not being child of Section inspection #1492
Conversation
…ds and offers quickfix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! I will look at it in more detail later, but here are already a few comments:
- Perhaps you can make it a weak warning (or info, I forgot how it's called) instead of a warning, because it's not really a LaTeX warning but more like a convention
- Can you also provide a quickfix to replace the sectioning command by the right level, in addition to the quickfix inserting the extra levels?
- I actually would restrict this to sectioning commands in the file, because this should not trigger a warning:
main.tex
:
\documentclass{article}
\begin{document}
\section{One}
\input{section1}
\end{document}
section1.tex
:
\subsection{Subsection 1}
Of course ideally you want to take into account al those includes too, but I think it might make the inspection too slow (or too complicated) for now.
I implemented your first two suggestions. |
Great, thanks! I just took a better look at the inspection, I agree to keep the paragraph separate but I wonder why you only check for subsubsection after section? Why not also check for subsection or subsubsection after chapter or part? (In this case, instead of checking the documentclass you could just assume part is level 0 to avoid false positives). |
…file_with_sub_command inspection
Unfortunately I can't spent too much time on it at the moment to do the check through the whole file hierarchy as you suggested in your first paragraph. But I included |
I agree this is better, it is immediately clear now when looking at the code what cases we check for. |
Inspection notices misplaced section and paragraph commands and offers quickfix
Fixes #1490
Summary of additions and changes
At first I thought it would be more straight forward, but the more I thought about it the more exceptions there are. But please tell me if you see a simpler solution.
I wasn't able to just use the Magic.Command.labeledLevels as it is e.g. okay (correct me if I'm wrong) to have a paragraph after a section. Also part and chapter are optional.
This now basically just tests that a document does not start with a
subsection
,subsubsection
orsubparagraph
, that asubsubsection
does not follow directly after asubsection
and that asubparagraph
follows anothersubparagraph
or aparagraph
.How to test this pull request
Some tests are included
Wiki