sbarex / SourceCodeSyntaxHighlight

Quick Look extension for highlight source code files on macOS 10.15 and later.
GNU General Public License v3.0
3.02k stars 72 forks source link

Fortran comments not recognized #178

Open zhyiyu opened 2 years ago

zhyiyu commented 2 years ago

Hi, seems like the following comments in Fortran are not recognized

fortran

(In Fortran 77, lines that has an * in the first column are comments.)

The format inquiry is attached:

inquiry
sbarex commented 2 years ago

Please enable the Debug mode on the General settings, then open a preview of a fortran file. On your Desktop will be created a colorize.log file. Search inside the row that begin with "Resolved to language: ". What value does it report?

zhyiyu commented 2 years ago

Sure, but I can not find the Debug mode:

general
sbarex commented 2 years ago

From View menu, check Show advanced settings

zhyiyu commented 2 years ago

Here is the line:

2022-06-10 20:59:05.000 Resolved to language: f

Here is the content of the whole file in case if needed:

2022-06-10 20:59:05.244 Start processing /Users/zyy/Desktop/lambpar.f …
2022-06-10 20:59:05.274 Detected UTI: public.fortran-source
2022-06-10 20:59:05.277 Highlight dataDir: /Applications/Syntax Highlight.app/Contents/Resources/highlight/share
2022-06-10 20:59:05.277 Highlight theme: /Applications/Syntax Highlight.app/Contents/Resources/highlight/share/themes/base16/atelier-dune-light
2022-06-10 20:59:05.278 Max data: 
2022-06-10 20:59:05.278 EOL conversion: off
2022-06-10 20:59:05.278 Start colorizing /Users/zyy/Desktop/lambpar.f …
2022-06-10 20:59:05.278 Executing '/Applications/Syntax Highlight.app/Contents/Resources/highlight/colorize.sh' '/Users/zyy/Desktop/lambpar.f'
2022-06-10 20:59:05.000 Starting colorize.sh
2022-06-10 20:59:05.000 # install gdate with `brew install coreutils` to show the nanoseconds time stamp #
2022-06-10 20:59:05.000 Target to colorize: /Users/zyy/Desktop/lambpar.f
2022-06-10 20:59:05.000 Resolved to language: f
2022-06-10 20:59:05.000 Reader: cat "/Users/zyy/Desktop/lambpar.f"
2022-06-10 20:59:05.000 Highlight: /Applications/Syntax Highlight.app/Contents/Resources/highlight/bin/highlight
2022-06-10 20:59:05.000 Generating the preview…
2022-06-10 20:59:05.000 $ cat "/Users/zyy/Desktop/lambpar.f" | "/Applications/Syntax Highlight.app/Contents/Resources/highlight/bin/highlight" -T "/Users/zyy/Desktop/lambpar.f" --syntax=f --quiet --include-style --encoding=UTF-8 --line-numbers --wrap-no-numbers --replace-tabs=4 --font=Menlo-Regular --font-size=12.00 --out-format=rtf --page-color --char-styles -v -v --data-dir=/Applications/Syntax Highlight.app/Contents/Resources/highlight/share --style=/Applications/Syntax Highlight.app/Contents/Resources/highlight/share/themes/base16/atelier-dune-light.theme --validate-input

Loading language definition:
/Applications/Syntax Highlight.app/Contents/Resources/highlight/share/langDefs/fortran77.lang

Description: Fortran 77

LUA GLOBALS:
AddKeyword: function
AddPersistentState: function
Categories: table
Comments: table
Description: string [ Fortran 77 ]
Digits: string [ (?:0x|0X)[0-9a-fA-F]+|\d*[\.]?\d+(?:[eE][\-\+]\d+)?[lLuU]* ]
DisableHighlighting: boolean [ 0 ]
EnableIndentation: boolean [ 0 ]
HL_BLOCK_COMMENT: number [ 4 ]
HL_BLOCK_COMMENT_END: number [ 17 ]
HL_EMBEDDED_CODE_BEGIN: number [ 25 ]
HL_EMBEDDED_CODE_END: number [ 26 ]
HL_ESC_SEQ: number [ 5 ]
HL_ESC_SEQ_END: number [ 18 ]
HL_FORMAT_ANSI: number [ 5 ]
HL_FORMAT_BBCODE: number [ 9 ]
HL_FORMAT_HTML: number [ 0 ]
HL_FORMAT_LATEX: number [ 3 ]
HL_FORMAT_ODT: number [ 11 ]
HL_FORMAT_PANGO: number [ 10 ]
HL_FORMAT_RTF: number [ 4 ]
HL_FORMAT_SVG: number [ 8 ]
HL_FORMAT_TEX: number [ 2 ]
HL_FORMAT_TRUECOLOR: number [ 7 ]
HL_FORMAT_XHTML: number [ 1 ]
HL_FORMAT_XTERM256: number [ 6 ]
HL_IDENTIFIER_BEGIN: number [ 23 ]
HL_IDENTIFIER_END: number [ 24 ]
HL_INTERPOLATION: number [ 10 ]
HL_INTERPOLATION_END: number [ 21 ]
HL_KEYWORD: number [ 13 ]
HL_KEYWORD_END: number [ 22 ]
HL_LANG_DIR: string [ /Applications/Syntax Highlight.app/Contents/Resources/highlight/share/langDefs/ ]
HL_LINENUMBER: number [ 8 ]
HL_LINE_COMMENT: number [ 3 ]
HL_LINE_COMMENT_END: number [ 16 ]
HL_NUMBER: number [ 2 ]
HL_OPERATOR: number [ 9 ]
HL_OPERATOR_END: number [ 20 ]
HL_OUTPUT: number [ 4 ]
HL_PLUGIN_PARAM: string [  ]
HL_PREPROC: number [ 6 ]
HL_PREPROC_END: number [ 19 ]
HL_PREPROC_STRING: number [ 7 ]
HL_REJECT: number [ 101 ]
HL_SRInstance: userdata
HL_STANDARD: number [ 0 ]
HL_STRING: number [ 1 ]
HL_STRING_END: number [ 14 ]
HL_UNKNOWN: number [ 100 ]
Identifiers: string [  [a-zA-Z_][\w\d\*]*  ]
IgnoreCase: boolean [ 1 ]
Keywords: table
Operators: string [ \(|\)|\[|\]|\{|\}|\,|\;|\:|\&|<|>|\!|\=|\/|\*|\%|\+|\-|\. ]
OverrideParam: function
RemoveKeyword: function
StoreValue: function
Strings: table
_VERSION: string [ Lua 5.4 ]
assert: function
collectgarbage: function
coroutine: table
debug: table
dofile: function
error: function
getmetatable: function
io: table
ipairs: function
load: function
loadfile: function
math: table
next: function
os: table
pairs: function
pcall: function
print: function
rawequal: function
rawget: function
rawlen: function
rawset: function
require: function
select: function
setmetatable: function
string: table
table: table
tonumber: function
tostring: function
type: function
utf8: table
warn: function
xpcall: function

REGEX:
State 3 (HL_LINE_COMMENT):  ^[cC].*
State 23 (HL_IDENTIFIER_BEGIN): [a-zA-Z_][\w\d\*]*
State 2 (HL_NUMBER):    (?:0x|0X)[0-9a-fA-F]+|\d*[\.]?\d+(?:[eE][\-\+]\d+)?[lLuU]*
State 1 (HL_STRING):    "|'
State 5 (HL_ESC_SEQ):   \\u[[:xdigit:]]{4}|\\\d{3}|\\x[[:xdigit:]]{2}|\\[ntvbrfa\\\?'"]
State 9 (HL_OPERATOR):  \(|\)|\[|\]|\{|\}|\,|\;|\:|\&|<|>|\!|\=|\/|\*|\%|\+|\-|\.

KEYWORDS:
 break(1) call(1) character(2) common(1) complex(2) continue(1) date(1) default(1) dimension(1) do(1) double(2) else(1) end(1) enddo(1) endif(1) external(2) for(1) format(1) function(1) go(1) goto(1) if(1) implicit(2) integer(2) logical(2) parameter(2) precision(2) program(1) read(1) real(2) real*8(2) return(1) stop(1) subroutine(1) switch(1) then(1) to(1) while(1) write(1)

2022-06-10 20:59:05.000 Success.
2022-06-10 20:59:05.318 

#######
# ENV:
LOGNAME=zyy
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.bxpbvD0lCD/Listeners
convertEOL=
HOME=/Users/zyy
extraFlagsHL=--line-numbers•--wrap-no-numbers•--replace-tabs=4•--font=Menlo-Regular•--font-size=12.00•--out-format=rtf•--page-color•--char-styles•-v•-v•--data-dir=/Applications/Syntax Highlight.app/Contents/Resources/highlight/share•--style=/Applications/Syntax Highlight.app/Contents/Resources/highlight/share/themes/base16/atelier-dune-light.theme
TMPDIR=/var/folders/70/w4h_qr6x56z8zf4p4ykkf12m0000gn/T/
logHL=/Users/zyy/Desktop/colorize.log
XPC_FLAGS=0x0
USER=zyy
maxFileSizeHL=
pathHL=/Applications/Syntax Highlight.app/Contents/Resources/highlight/bin/highlight
pathDos2unix=/Applications/Syntax Highlight.app/Contents/Resources/dos2unix
__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0
SHELL=/bin/zsh
XPC_SERVICE_NAME=org.sbarex.SourceCodeSyntaxHighlight.XPCRender
HIGHLIGHT_DATADIR=/Applications/Syntax Highlight.app/Contents/Resources/highlight/share
textEncoding=UTF-8
webkitTextEncoding=UTF-8
PATH=/usr/bin:/bin:/usr/sbin:/sbin

####### ENV end
sbarex commented 2 years ago

Please send me a fortran file to make more test. It could be a bug of the rendering engine.

zhyiyu commented 2 years ago

Here you are

********************************************************************
*                                                                  *
*          UNPOLARIZED AND POLARIZED FRAGMENTATION FUNCTIONS       *
*                     FOR LAMBDA - BARYONS                         *
*               D. DE FLORIAN, M. STRATMANN, W. VOGELSANG          *
*                                                                  *
*   INPUT:   ISET = number of the parton set :                     *
*              ISET = 1  NLO UNPOLARIZED                           *
*                        (DATA FILE 'unpnlo.grid' UNIT=11)         *
*              ISET = 2  LO UNPOLARIZED                            *
*                        (DATA FILE 'unplo.grid' UNIT=21)          *
*                                                                  *
*              ISET = 3  NLO POLARIZED SCENARIO 1                  *
*                        (DATA FILE 'pnlo1.grid' UNIT=12)          *
*              ISET = 4  NLO POLARIZED SCENARIO 2                  *
*                        (DATA FILE 'pnlo2.grid' UNIT=13)          *
*              ISET = 5  NLO POLARIZED SCENARIO 3                  *
*                        (DATA FILE 'pnlo3.grid' UNIT=14)          *
*              ISET = 6  LO POLARIZED SCENARIO 1                   *
*                        (DATA FILE 'plo1.grid' UNIT=22)           *
*              ISET = 7  LO POLARIZED SCENARIO 2                   *
*                        (DATA FILE 'plo2.grid' UNIT=23)           *
*              ISET = 8  LO POLARIZED SCENARIO 3                   *
*                        (DATA FILE 'plo3.grid' UNIT=24)           *
*                                                                  *
*            Z                    (between  0.05   and  1.0)       *
*            Q2 = scale in GeV**2 (between  1.0    and  1.D4)      *
*             (for values outside the allowed range the program    *
*              writes a warning and extrapolates to the x and      *
*              Q2 values requested)                                *
*                                                                  *
*   OUTPUT:  UTOT/DTOT/STOT/CTOT/BTOT/GL/UVAL/DVAL/SVAL            *
*             UTOT means U+Ubar ...                                *
*             UVAL/DVAL/SVAL only for the polarized case           *
*            Always LAMBDA/LAMBDAbar                               *
*            Always x times the distribution is returned           *
*                                                                  *
*                                                                  *
*   COMMON:  The main program or the calling routine has to have   *
*            a common block  COMMON / FRAGINI / FINI , and  FINI   *
*            has always to be zero when PARPOL is called for the   *
*            first time or when 'ISET' has been changed.           *
*                                                                  *
********************************************************************
*
      SUBROUTINE FRAGPAR (ISET, X, Q2, UTOT, DTOT, STOT, CTOT)
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
      INTEGER FINI
      PARAMETER (NPART=9, NX=33, NQ=20, NARG=2)

      UTOT = FINT(NARG,XT,NA,ARRF,XUTOTF) * (1.D0-X)**4 * X**0.5
      RETURN
      END
sbarex commented 2 years ago

I open an issue for the render engine to fix this bug.