git: 4cb922f185 - main - Update nano config for adoc files

From: Muhammad Moinur Rahman <bofh_at_FreeBSD.org>
Date: Sun, 26 Jun 2022 22:57:44 UTC
The branch main has been updated by bofh (ports committer):

URL: https://cgit.FreeBSD.org/doc/commit/?id=4cb922f1851bea57d264724cc5a81d5b3b6fcdfa

commit 4cb922f1851bea57d264724cc5a81d5b3b6fcdfa
Author:     Muhammad Moinur Rahman <bofh@FreeBSD.org>
AuthorDate: 2022-06-26 22:55:52 +0000
Commit:     Muhammad Moinur Rahman <bofh@FreeBSD.org>
CommitDate: 2022-06-26 22:55:52 +0000

    Update nano config for adoc files
    
    en/books/fdp-primer/book/#editor-config-nano
    
    section still refers to the old xml syntax. This patch updates the
    config to support adoc documents. Additionally:
    - The syntax highlight is collected from different locations in the web
    - Remove line-wrapping related stuffs as in ASCIIDOC we can have longer
      lines as there is a rule "one sentence per line".
    
    PR:             264899
    Obtained from:  crees
---
 .../en/books/fdp-primer/editor-config/_index.adoc  | 53 +++++++++++++++++-----
 1 file changed, 41 insertions(+), 12 deletions(-)

diff --git a/documentation/content/en/books/fdp-primer/editor-config/_index.adoc b/documentation/content/en/books/fdp-primer/editor-config/_index.adoc
index 3c865efb2b..d034d87737 100644
--- a/documentation/content/en/books/fdp-primer/editor-config/_index.adoc
+++ b/documentation/content/en/books/fdp-primer/editor-config/_index.adoc
@@ -191,17 +191,48 @@ Install from package:editors/nano[] or package:editors/nano-devel[].
 [[editor-config-nano-config]]
 === Configuration
 
-Copy the sample XML syntax highlight file to the user's home directory:
-
-[source,shell]
-....
-% cp /usr/local/share/nano/xml.nanorc ~/.nanorc
-....
-
-Use an editor to replace the lines in the [.filename]#~/.nanorc# `syntax "xml"` block with these rules:
+Currently there is no adoc/asciidoc syntax highlight file with nano distribution. So let's create one from scratch and use an editor to create new file or add lines in the [.filename]#~/.nanorc# with these contents:
 
 ....
-syntax "xml" "\.([jrs]html?|xml|xslt?)$"
+syntax "asciidoc" "\.(adoc|asc|asciidoc)$"
+# main header
+color red "^====+$"
+# h1
+color red "^==[[:space:]].*$"
+color red "^----+$"
+# h2
+color magenta "^===[[:space:]].*$"
+color magenta "^~~~~+$"
+# h4
+color green "^====[[:space:]].*$"
+color green "^\^\^\^\^+$"
+# h5
+color brightblue "^=====[[:space:]].*$"
+color brightblue "^\+\+\+\++$"
+# attributes
+color brightgreen ":.*:"
+color brightred "\{[a-z0-9]*\}"
+color red "\\\{[a-z0-9]*\}"
+color red "\+\+\+\{[a-z0-9]*\}\+\+\+"
+# Paragraph Title
+color yellow "^\..*$"
+# source
+color magenta "^\[(source,.+|NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]"
+# Other markup
+color yellow ".*[[:space:]]\+$"
+color yellow "_[^_]+_"
+color yellow "\*[^\*]+\*"
+color yellow "\+[^\+]+\+"
+color yellow "`[^`]+`"
+color yellow "\^[^\^]+\^"
+color yellow "~[^~]+~"
+color yellow "'[^']+'"
+color cyan "`{1,2}[^']+'{1,2}"
+# bullets
+color brightmagenta "^[[:space:]]*[\*\.-]{1,5}[[:space:]]"
+# anchors
+color brightwhite "\[\[.*\]\]"
+color brightwhite "<<.*>>"
 # trailing whitespace
 color ,blue "[[:space:]]+$"
 # multiples of eight spaces at the start a line
@@ -211,8 +242,6 @@ color ,blue "^([TAB]*[ ]{8})+"
 color ,yellow "( )+TAB"
 # highlight indents that have an odd number of spaces
 color ,red "^(([ ]{2})+|(TAB+))*[ ]{1}[^ ]{1}"
-# lines longer than 70 characters
-color ,yellow "^(.{71})|(TAB.{63})|(TAB{2}.{55})|(TAB{3}.{47}).+$"
 ....
 
 Process the file to create embedded tabs:
@@ -229,7 +258,7 @@ Specify additional helpful options when running the editor:
 
 [source,shell]
 ....
-% nano -AKipwz -r 70 -T8 _index.adoc
+% nano -AKipwz -T8 _index.adoc
 ....
 
 Users of man:csh[1] can define an alias in [.filename]#~/.cshrc# to automate these options: