forked from sylvainhalle/textidote
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
25ddede
commit 44ec724
Showing
14 changed files
with
515 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
Rules checked by TeXtidote | ||
========================== | ||
|
||
Style | ||
----- | ||
|
||
- A section title should start with a capital letter. [sh:001] | ||
- A section title should not end with a punctuation symbol. [sh:002] | ||
- A section title should not be written in all caps. The LaTeX stylesheet | ||
takes care of rendering titles in caps if needed. [sh:003] | ||
- A figure caption should end with a period. [sh:004] | ||
|
||
Citations and references | ||
------------------------ | ||
|
||
- There should be one space before a \cite or \ref command [sh:c:001], and | ||
no space after [sh:c:002]. | ||
|
||
Figures | ||
------- | ||
- Every figure should have a label, and every figure should be referenced at | ||
least once in the text. [sh:figref] | ||
- Figures should not refer to hard-coded local paths. [sh:relpath] | ||
|
||
Typesetting | ||
----------- | ||
|
||
- You should not break lines manually in a paragraph. Either start a new | ||
paragraph or stay in the current one. [sh:nobreak] | ||
|
||
Structure | ||
--------- | ||
|
||
- A section should not contain a single sub-section. More generally, a division | ||
of level n should not contain a single division of level n+1. [sh:nsubdiv] | ||
|
||
Potentially suspicious | ||
---------------------- | ||
|
||
- There should be at least N words between two section headings (currently | ||
N=50). [sh:seclen] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<hr/> | ||
Output produced by TeXtidote, © 2018 Sylvain Hallé - All rights reserved.<br/> | ||
See the <a href="https://github.com/sylvainhalle/texlint">TeXLint website</a> for more information. | ||
See the <a href="https://sylvainhalle.github.io/sylvainhalle/textidote">TeXtidote website</a> for more information. | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
Source/Core/src/ca/uqac/lif/textidote/rules/CheckNoBreak.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
TeXtidote, a linter for LaTeX documents | ||
Copyright (C) 2018 Sylvain Hallé | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
package ca.uqac.lif.textidote.rules; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
import ca.uqac.lif.textidote.Advice; | ||
import ca.uqac.lif.textidote.Rule; | ||
import ca.uqac.lif.textidote.as.AnnotatedString; | ||
import ca.uqac.lif.textidote.as.Position; | ||
import ca.uqac.lif.textidote.as.Range; | ||
|
||
/** | ||
* Checks that text paragraphs do not contain forced line breaks. | ||
* | ||
* @author Sylvain Hallé | ||
* | ||
*/ | ||
public class CheckNoBreak extends Rule | ||
{ | ||
/** | ||
* The pattern for finding figure labels | ||
*/ | ||
Pattern m_breakPattern = Pattern.compile("\\\\\\\\"); | ||
|
||
public CheckNoBreak() | ||
{ | ||
super("sh:nobreak"); | ||
} | ||
|
||
@Override | ||
public List<Advice> evaluate(AnnotatedString s, AnnotatedString original) | ||
{ | ||
List<Advice> out_list = new ArrayList<Advice>(); | ||
List<String> lines = s.getLines(); | ||
int env_level = 0; | ||
for (int line_cnt = 0; line_cnt < lines.size(); line_cnt++) | ||
{ | ||
String line = lines.get(line_cnt); | ||
if (line.matches(".*\\\\begin\\s*\\{\\s*(equation|table|tabular|verbatim|lstlisting|IEEEkeywords|figure).*") || line.matches(".*\\\\\\[.*")) | ||
{ | ||
env_level++; | ||
} | ||
if (env_level == 0) | ||
{ | ||
Matcher mat = m_breakPattern.matcher(line); | ||
if (mat.find()) | ||
{ | ||
// Forced break | ||
Position start_pos = s.getSourcePosition(new Position(line_cnt, mat.start())); | ||
Position end_pos = s.getSourcePosition(new Position(line_cnt, mat.start() + mat.group(0).length())); | ||
Range r = new Range(start_pos, end_pos); | ||
out_list.add(new Advice(this, r, "You should not break lines manually in a paragraph. Either start a new paragraph or stay in the current one.", original.getResourceName(), original.getLine(start_pos.getLine()))); | ||
} | ||
} | ||
if (line.matches(".*\\\\end\\s*\\{\\s*(equation|table|tabular|verbatim|lstlisting|IEEEkeywords|figure).*") || line.matches(".*\\\\\\].*")) | ||
{ | ||
env_level--; | ||
} | ||
} | ||
return out_list; | ||
} | ||
} |
Oops, something went wrong.