Skip to content

Commit

Permalink
Replace (frankly atrocious) html.nanorc I can't seem to find the true…
Browse files Browse the repository at this point in the history
… origin of with a modified version of the file from scopatz's repository (https://github.com/scopatz/nanorc). Modifications include basic highlighting the contents of script and style tag blocks, specifying tidy (html-tidy) as a formatter, and applying the highlighting to mhtml files (which, though far from perfect, is a huge improvement).
  • Loading branch information
StaticPH committed Aug 25, 2022
1 parent 54f5873 commit 553171b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 20 deletions.
3 changes: 2 additions & 1 deletion .config/nano/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* csh.nanorc
* css.nanorc
* etc-hosts.nanorc
* html.nanorc
* inputrc.nanorc
* java.nanorc
* json.nanorc
Expand All @@ -35,6 +34,7 @@

# Modified:
* git.nanorc
* html.nanorc
* markdown.nanorc
* nanohelp.nanorc
* toml.nanorc
Expand All @@ -47,3 +47,4 @@
* Update markdown syntax rules, taking inspiration from the rules provided with nano by default (/usr/share/nano/markdown.nanorc). Alternatively, just use the default.
* Extensively review troff syntax and update man syntax rules (low priority). Alternatively, just use the default.
* Deprecate various copied files for the builtin defaults
* Incorporate highlighting of CSS property names and delimiting semicolons into the style attribute of html elements in html.nanorc
65 changes: 46 additions & 19 deletions .config/nano/html.nanorc
Original file line number Diff line number Diff line change
@@ -1,19 +1,46 @@
############## HTML example
##
syntax "html" "\.htm[l]?$"
#
#Assorted Brackets, separators, and functions
color brightblue start="<" end=">"
#color blue start="<style>" end="</style>"
color brightblue "<script>|</script>|<div>|</div>|</a>|<select>|</select>|<style>|</style>"
color brightblue "<h(1|2|3|4|5|6)>|</h(1|2|3|4|5|6)>"
color brightblue start="<div" end=">"
color brightblue start="<a " end=">"
#color red " action | checked | class | contextmenu | dir | for | href | id | lang | method | name | onclick | rel | src | style | tabindex | title | type | value "
#
color brightred "(alt|bgcolor|height|href|label|longdesc|name|onclick|onfocus|onload|onmouseover|size|span|src|style|target|type|value|width)="
color red "&[^;[[:space:]]]*;"
color magenta ""[^"]*"|qq\|.*\|"
#
#Comment coloring is last
color green start="<!--" end="-->"
## HTML syntax highlighting rules for Nano

syntax "HTML" "\.html?(.j2)?(.twig)?$" "\.mhtml$"
magic "HTML document"
comment "<!--|-->"
formatter tidy -m -q

## Tag content blocks
color latte,lightblack start="<script[^>]*>" end="</script>"
color orange,lightblack start="<style[^>]*>" end="</style>"

## Emphasis tags
color brightwhite start="<([biu]|em|strong)[^>]*>" end="</([biu]|em|strong)>"

## Tags
color cyan start="<" end=">"

## Attributes
color brightblue "[[:space:]](abbr|accept(-charset)?|accesskey|action|[av]?link|alt|archive|axis|background|(bg)?color|border)="
color brightblue "[[:space:]](cell(padding|spacing)|char(off|set)?|checked|cite|class(id)?|compact|code(base|tag)?|cols(pan)?)="
color brightblue "[[:space:]](content(editable)?|contextmenu|coords|data|datetime|declare|defer|dir|enctype)="
color brightblue "[[:space:]](for|frame(border)?|headers|height|hidden|href(lang)?|hspace|http-equiv|id|ismap)="
color brightblue "[[:space:]](label|lang|longdesc|margin(height|width)|maxlength|media|method|multiple)="
color brightblue "[[:space:]](name|nohref|noresize|noshade|object|on(click|focus|load|mouseover|keypress)|profile|readonly|rel|rev)="
color brightblue "[[:space:]](rows(pan)?|rules|scheme|scope|scrolling|shape|size|span|src|standby|start|style|summary|pattern)="
color brightblue "[[:space:]](tabindex|target|text|title|type|usemap|v?align|value(type)?|vspace|width|xmlns|xml:space)="
color brightblue "[[:space:]](required|disabled|selected)[[:space:]=>]"

## Strings
color yellow ""(\\.|[^"])*""

## Named character references and entities
color red "&#?[[:alnum:]]*;"

## Template strings (not in the HTML spec, but very commonly used)
color magenta "\{[^\}]*\}\}?"
color brightgreen "[[:space:]]((end)?if|(end)?for|in|not|(end)?block)[[:space:]]"

## Comments
color green start="<!--" end="-->"

## Trailing spaces
color ,green "[[:space:]]+$"

## Reminders
color brightwhite,yellow "(FIXME|TODO|XXX)"

0 comments on commit 553171b

Please sign in to comment.