diff options
authorMuhammad Moinur Rahman <bofh@FreeBSD.org>2022-06-26 22:55:52 +0000
committerMuhammad Moinur Rahman <bofh@FreeBSD.org>2022-06-26 22:55:52 +0000
commit4cb922f1851bea57d264724cc5a81d5b3b6fcdfa (patch)
parent62f6d393eae561326d3846061a24d61aeb4089db (diff)
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
1 files 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[].
=== Configuration
-Copy the sample XML syntax highlight file to the user's home directory:
-% 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:
-% 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: