0

My nano doesn't want to display syntax highlighting for html.

My ~/.nanorc contains the following:

include ~/.nano/syntax/html.nanorc
include ~/.nano/syntax/css.nanorc
include ~/.nano/syntax/php.nanorc
include ~/.nano/syntax/python.nanorc

And it works for css, php and python. I tried commenting out their lines and the syntax highlighting stopped.

I also tried changing colors of things in the respective files and the highlighting changed.

The html.nanorc contains:

syntax "html" "\.html?$"
header "<!doctype html"

color magenta "\<(accept|accept-charset|accesskey|action|alt|async|autocomplete|autofocus|autoplay|border|challenge|charset|checked|cite|class|cols|cols$
color brightwhite,red   "</?[A-Za-z0-9_]+[ >]"
color brightmagenta       "</?(a|abbr|address|area|article|aside|audio|b|base|bdo|blockquote|body|br|button|center|canvas|caption|cite|code|col|colgroup$
color yellow    "=([A-Za-z0-9!$%*\^(){}#|:;_~@+,.?/\\-]|\[|\])+"
color red  "="
color yellow ""(\\.|[^"])*"|'(\\.|[^'])*'"
color white     start=">" end="<"
color brightmagenta       "[<>]"

# Embedded template languages
color brightyellow  "\{\{[^}]*\}\}|<%=.*%>"
color brightblue  start="<\?" end="\?>"
color brightblue  start="<%[^=]" end="%>"
color brightblue  start="\{%" end="%\}"

color magenta    "&(#[0-9]+|#x[0-9a-fA-F]+|[A-Za-z][A-Za-z0-9]*);"
color cyan   start="<!--" end="-->"
color cyan   "<!(doctype|DOCTYPE)[^>]*>"
color ,green "[[:space:]]+$"
color ,red "    + +| +  +"
# +EXTRALINT

And I can't find anything wrong with it.

When I open a html file with

nano test.html

all the text is just white/grey. HOWEVER, if i run it as root with

sudo nano test.html

the highlighting works.

My nano and debian version is

GNU nano version 2.2.6 (compiled 16:56:37, Jul 16 2014)
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 8.11 (jessie)
Release:        8.11
Codename:       jessie
Linux <server> 3.16.0-6-amd64 #1 SMP Debian 3.16.57-2 (2018-07-14) x86_64 GNU/Linux

I don't really know how to continue from where so would really appreciate some help.

chanpa
  • 95
  • 8

1 Answers1

0

Found my answer here: Nano on server ignores certain syntax coloring

I don't know why, but if I moved the include html line to the bottom of my .nanorc file instead of at the top, it works.

I tested all the extensions that I have included and they all work after I changed the order of the inclusions.

chanpa
  • 95
  • 8