Skip to content
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

[LaTeX] Refactor LaTeX log file syntax #4136

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions LaTeX/LaTeX Log Fold.tmPreferences
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>scope</key>
<string>text.log.latex</string>
<key>settings</key>
<dict>
<key>indentationFoldingEnabled</key>
<false/>
<key>foldScopes</key>
<array>
<dict>
<key>begin</key>
<string>punctuation.section.block.begin</string>
<key>end</key>
<string>punctuation.section.block.end</string>
<key>excludeTrailingNewlines</key>
<false/>
</dict>
<dict>
<key>begin</key>
<string>punctuation.section.group.begin</string>
<key>end</key>
<string>punctuation.section.group.end</string>
<key>excludeTrailingNewlines</key>
<false/>
</dict>
</array>
</dict>
</dict>
</plist>
221 changes: 149 additions & 72 deletions LaTeX/LaTeX Log.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -4,100 +4,177 @@ name: LaTeX Log
scope: text.log.latex
version: 2

first_line_match: 'This is (pdf|pdfe)?TeXk?, Version '
first_line_match: '^This is (?:LuaHB|pdfe?|Xe)?TeXk?, Version '

################################################################################

contexts:
main:
- include: log-entries
- include: file-paths
- include: under-over-full
- include: comments
- include: blocks
- include: strings

under-over-full:
- match: (?:Overfull|Underfull)
scope: keyword.control.hyphenation.latex
push: under-over-full-body
comments:
# note: primarily used for syntax_test files
- match: \#
scope: punctuation.definition.comment.log
push: comment-body

under-over-full-body:
- meta_scope: meta.log.latex.hyphenation
- match: \[\]\n
scope: keyword.control.hyphenation.latex
comment-body:
- meta_scope: comment.line.log
- match: $\n?
pop: 1
- match: '[0-9]+\-\-[0-9]+'
scope: variable.parameter.hyphenation.latex

###[ File paths ]###############################################################

file-paths:
- include: function-file-paths
- include: tag-file-paths
- include: type-file-paths

function-file-paths:
- match: .*\.sty
scope: entity.name.function

tag-file-paths:
- match: .*\.cfg
scope: entity.name.tag.configuration
- match: .*\.def
scope: entity.name.tag.definition

type-file-paths:
- match: .*\.cls
scope: entity.name.type.class
###[ BLOCKS ]##################################################################

blocks:
# block begin with full file name
- match: (\()((?:\\.|[^\s?!*)])+\.[A-Za-z]{2,}\b)
captures:
1: punctuation.section.block.begin.log
2: meta.toc-list.log entity.name.section.filename.log
push:
- block-body
- block-comment
# block begin with wrapped file name
- match: (\()((?:\\.|[^\s?!*)])+\n)
captures:
1: punctuation.section.block.begin.log
2: meta.toc-list.log entity.name.section.filename.log
push:
- block-body
- block-comment
- filename-continuation

filename-continuation:
- match: ((?:\\.|[^\s?!*)])+\.[A-Za-z]{2,}\b)
scope: meta.toc-list.log entity.name.section.filename.log
pop: 1
- match: (?=\S)
pop: 1

###[ Log entries ]##############################################################
block-body:
- meta_scope: meta.block.log
- match: \)
scope: punctuation.section.block.end.log
pop: 1
- include: comments
- include: blocks
- include: groups
- include: log-entries
- include: commands
- include: strings

log-entries:
- include: error-log-entries
- include: warning-log-entries
- include: info-log-entries
- include: fixme-log-entries
block-comment:
- match: '^Document Class:.{64}\n'
set: block-comment-body
- match: '^Document Class:.+'
scope: comment.line.log
pop: 1
- match: '^File:.{74}\n'
set: block-comment-body
- match: '^File:.+'
scope: comment.line.log
pop: 1
- match: '^Package:.{71}\n'
set: block-comment-body
- match: '^Package:.+'
scope: comment.line.log
pop: 1
- match: ^|(?=\))
pop: 1

error-log-entries:
- match: '.*Error|^!.*'
scope: invalid.illegal
block-comment-body:
- meta_scope: comment.line.log
- match: ^.{80}\n # consume anything which has 80 chars
- match: \n
pop: 1

warning-log-entries:
- match: '.*Warning:'
scope: invalid.deprecated
- match: '[^:]*:\d*:.*'
scope: invalid.deprecated
groups:
- match: \(
scope: punctuation.section.group.begin.log
push: group-body

info-log-entries:
- match: '.*Info.*'
scope: comment.block.documentation
group-body:
- meta_scope: meta.group.log
- match: \)
scope: punctuation.section.group.end.log
pop: 1
- include: comments
- include: groups
- include: log-entries
- include: commands
- include: strings

fixme-log-entries:
- match: '.*FiXme:'
scope: meta.log.latex.fixme
###[ LOG ENTRIES ]##############################################################

###[ Strings ]##################################################################
log-entries:
# errors
- match: '^[^:]*Error:'
scope: markup.error.log
- match: '^!.*'
scope: markup.error.log
# warnings
- match: '^[^:]*(?:Overfull|Underfull)'
scope: markup.warning.log
push: box-warning-body
- match: '^[^:]*(FiXme|Warning):'
scope: markup.warning.log
- match: '^[^:]*:\d*:.*'
scope: markup.warning.log
# info
- match: '^[^:]*Info:'
scope: markup.info.log

box-warning-body:
- meta_scope: meta.warning.box.log
- match: ^\s*\[\]\n
scope: punctuation.terminator.log
pop: 1
- include: comments
- include: groups
- include: commands

commands:
- match: (\\)[\w@]+
scope: support.function.latex
captures:
1: punctuation.definition.variable.latex
- match: :?=
scope: keyword.operator.assignment.latex
- match: ;
scope: punctuation.separator.latex

###[ STRINGS ]##################################################################

strings:
- include: angle-bracket-strings

angle-bracket-strings:
- match: '<<'
scope: punctuation.definition.string.begin.log
push: double-angled-string-body
- match: '<'
scope: punctuation.definition.string.begin.log.latex
push: angle-bracket-string-content
scope: punctuation.definition.string.begin.log
push: single-angled-string-body
- match: '`'
scope: punctuation.definition.string.begin.log
push: single-quoted-string-body

double-angled-string-body:
- meta_scope: string.quoted.other.log
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo?

- match: '>>'
scope: punctuation.definition.string.end.log
pop: 1

angle-bracket-string-content:
- meta_scope: string.unquoted.other.filename.log.latex
single-angled-string-body:
- meta_scope: string.quoted.other.log
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo?

Copy link
Collaborator Author

@deathaxe deathaxe Jan 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Angled?

https://www.thesaurus.com/e/grammar/angle-brackets/

Due to single-/double- requirement I shorted the rest a bit.

- match: '>'
scope: punctuation.definition.string.end.log.latex
scope: punctuation.definition.string.end.log
pop: 1
- match: .*/.*\.pdf
scope:
support.function.with-arg.latex
entity.name.function.filename.latex
- include: eol-pop

###[ Helpers ]##################################################################

eol-pop:
- match: $\n?
single-quoted-string-body:
- meta_scope: string.quoted.single.log
- match: ''''
scope: punctuation.definition.string.end.log
pop: 1
- match: \.$
scope: punctuation.definition.string.end.log
pop: 1
Loading
Loading