diff options
author | John Ankarström <john@ankarstrom.se> | 2022-06-15 18:29:41 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-06-15 18:29:41 +0200 |
commit | bda0c167e13282185609619c63dd0b12164ae3cf (patch) | |
tree | 4e55b1631730bf8dc9f565c3f6863436c0687468 | |
parent | 4b03365723a61dcad79e6df3052621382702f0b3 (diff) | |
download | lightroff-master.tar.gz |
-rw-r--r-- | .gitignore | 5 | ||||
-rw-r--r-- | Makefile | 12 | ||||
-rw-r--r-- | README | 48 | ||||
-rw-r--r-- | README.l | 62 | ||||
-rw-r--r-- | README.t | 32 | ||||
-rw-r--r-- | README.x | 62 | ||||
-rw-r--r-- | lightroff.el (renamed from xroff.el) | 58 | ||||
-rw-r--r-- | lightroff.lex (renamed from xroff.lex) | 0 |
8 files changed, 140 insertions, 139 deletions
@@ -1,6 +1,7 @@ *~ lex.yy.c -xroff -xroff.exe +lightroff +lightroff.exe *.pdf *.ps +ws/* @@ -1,13 +1,13 @@ CC = gcc -xroff: lex.yy.c - $(CC) $(CFLAGS) $(LDFLAGS) -o xroff lex.yy.c +lightroff: lex.yy.c + $(CC) $(CFLAGS) $(LDFLAGS) -o lightroff lex.yy.c -lex.yy.c: xroff.lex - flex xroff.lex +lex.yy.c: lightroff.lex + flex lightroff.lex README: README.t <README.t groff -ms -Tutf8 | sed "s/\x1b\[[0-9;]*[a-zA-Z]//g" >README -README.t: README.x - <README.x ./xroff >README.t +README.t: README.l + <README.l ./lightroff >README.t @@ -7,7 +7,7 @@ - Xroff, an alternative troff syntax + Lightroff, an alternative troff syntax John Ankarström @@ -15,24 +15,24 @@ Introduction -Xroff is an alternative syntax for troff, visually inspired -by SGML/XML. It differs from troff’s default syntax in the -following ways: +Lightroff is an alternative syntax for troff, visually in‐ +spired by SGML/XML. It differs from troff’s default syntax +in the following ways: -1. Xroff requests begin with a less‐than sign and end with a - greater‐than sign, e.g., <SH 1>. These symbols may be es‐ - caped with a backslash.* +1. Lightroff requests begin with a less‐than sign and end + with a greater‐than sign, e.g., <SH 1>. These symbols may + be escaped with a backslash.* -2. Xroff requests may be used inline. The following works as - expected: (<ft B>bold<ft R>).** +2. Lightroff requests may be used inline. The following + works as expected: (<ft B>bold<ft R>).** -3. Xroff ignores empty lines. +3. Lightroff ignores empty lines. 4. Default troff syntax may be used between <![ and ]>. The similarities with XML end at the visual level. Unlike -XML, xroff is unstructured and imperative. There is no con‐ -cept of closing tags. +XML, lightroff is unstructured and imperative. There is no +concept of closing tags. Example @@ -56,8 +56,8 @@ Example with a newline and a control character, usually a period or an apostrophe, and end with another new‐ line. - ** Before an inline request, xroff automatically -inserts a \c escape when appropriate. + ** Before an inline request, lightroff automati‐ +cally inserts a \c escape when appropriate. @@ -70,22 +70,22 @@ inserts a \c escape when appropriate. ‐2‐ -Xroff +Lightroff -The program xroff translates xroff source to troff source. +The program lightroff translates lightroff source to troff +source. -Xroff‐mode +Lightroff‐mode -For Emacs users, there is a major mode named xroff‐mode that -provides syntax highlighting for xroff source. To further -improve the writing experience, I also recommend olivetti‐ -mode. +For Emacs users, there is a major mode named lightroff‐mode +that provides syntax highlighting for lightroff source. To +further improve the writing experience, I also recommend +olivetti‐mode. Caveats -Xroff does not treat indented lines specially. As such, in‐ -dentation cannot be used to convey structure. - +Lightroff does not treat indented lines specially. As such, +indentation cannot be used to convey structure. diff --git a/README.l b/README.l new file mode 100644 index 0000000..3c92fa6 --- /dev/null +++ b/README.l @@ -0,0 +1,62 @@ +<!-- -*- mode: lightroff; mode: olivetti -*- --> + + +<ss 12 0> +<nr PI 0> +<nr PD 0.5v> +<if n .nr PD 1v> +<de i>\\fI\\$*\\fR<.> +<de bi>\\f(BI\\$*\\fB<.> +<de cw>\\f(CW\\$*\\fR<.> +<de cwb>\\f(CB\\$*\\fR<.> + + +<TL><bi Lightroff>, an alternative troff syntax +<AU>John Ankarstrm +<DA 10 June 2022> + + +<SH 1>Introduction +<LP><i Lightroff> is an alternative syntax for troff, visually inspired by SGML/XML. It differs from troff's default syntax in the following ways: + +<IP 1. 3>Lightroff requests begin with a less-than sign and end with a greater-than sign, e.g., <cw <SH 1\>>. These symbols may be escaped with a backslash.* +<IP 2.>Lightroff requests may be used inline. The following works as expected: <cw "(<ft B\>bold<ft R\>)">.** +<IP 3.>Lightroff ignores empty lines. +<IP 4.>Default troff syntax may be used between <cw <![> and <cw ]\>>. + +<LP>The similarities with XML end at the visual level. Unlike XML, lightroff is unstructured and imperative. There is no concept of closing tags. + +<FS *>For comparison, default troff requests begin with a newline and a control character, usually a period or an apostrophe, and end with another newline.<FE> + +<FS **>Before an inline request, <cw lightroff> automatically inserts a <cw \\\\c> escape when appropriate.<FE> + + +<SH 1>Example +<IP "" 3><nf><eo><![ +<de b>\\fB\\$*\\fR<.> + +<TL>Example document +<AU>John Doe + +<AB>Pellentesque dapibus suscipit ligula. Donec posuere augue in quam. +Etiam vel tortor sodales tellus ultricies commodo. Suspendisse +potenti. Aenean in sem ac leo mollis blandit. Donec neque quam, +dignissim in, mollis nec, sagittis eu, wisi.<AE> + +<SH 1>Introduction +<LP><b Nullam eu ante> vel est convallis dignissim. Fusce suscipit, +wisi nec facilisis facilisis, est dui fermentum leo, quis tempor +ligula erat quis odio. Nunc porta vulputate tellus. +]><ec> + + +<SH 1><cwb Lightroff> +<PP>The program <cw lightroff> translates lightroff source to troff source. + + +<SH 1><cwb Lightroff-mode> +<PP>For Emacs users, there is a major mode named <cw lightroff-mode> that provides syntax highlighting for lightroff source. To further improve the writing experience, I also recommend <cw olivetti-mode>. + + +<SH 1>Caveats +<LP>Lightroff does not treat indented lines specially. As such, indentation cannot be used to convey structure. @@ -15,7 +15,7 @@ \\f(CB\\$*\\fR\c .. .TL -.bi Xroff +.bi Lightroff , an alternative troff syntax .AU John Ankarstrm @@ -23,32 +23,32 @@ John Ankarstrm .SH 1 Introduction .LP -.i Xroff +.i Lightroff is an alternative syntax for troff, visually inspired by SGML/XML. It differs from troff's default syntax in the following ways: .IP 1. 3 -Xroff requests begin with a less-than sign and end with a greater-than sign, e.g., \c +Lightroff requests begin with a less-than sign and end with a greater-than sign, e.g., \c .cw \<SH 1> \&. These symbols may be escaped with a backslash.* .IP 2. -Xroff requests may be used inline. The following works as expected: \c -.cw "(\<ft B>bold\<ft R>)" +Lightroff requests may be used inline. The following works as expected: \c +.cw "(<ft B>bold<ft R>)" \&.** .IP 3. -Xroff ignores empty lines. +Lightroff ignores empty lines. .IP 4. Default troff syntax may be used between \c -.cw \<![ +.cw <![ and \c .cw ]> \&. .LP -The similarities with XML end at the visual level. Unlike XML, xroff is unstructured and imperative. There is no concept of closing tags. +The similarities with XML end at the visual level. Unlike XML, lightroff is unstructured and imperative. There is no concept of closing tags. .FS * For comparison, default troff requests begin with a newline and a control character, usually a period or an apostrophe, and end with another newline.\c .FE .FS ** Before an inline request, \c -.cw xroff +.cw lightroff automatically inserts a \c .cw \\\\c escape when appropriate.\c @@ -74,20 +74,20 @@ wisi nec facilisis facilisis, est dui fermentum leo, quis tempor ligula erat quis odio. Nunc porta vulputate tellus. .ec .SH 1 -.cwb Xroff +.cwb Lightroff .PP The program \c -.cw xroff - translates xroff source to troff source. +.cw lightroff + translates lightroff source to troff source. .SH 1 -.cwb Xroff-mode +.cwb Lightroff-mode .PP For Emacs users, there is a major mode named \c -.cw xroff-mode - that provides syntax highlighting for xroff source. To further improve the writing experience, I also recommend \c +.cw lightroff-mode + that provides syntax highlighting for lightroff source. To further improve the writing experience, I also recommend \c .cw olivetti-mode \&. .SH 1 Caveats .LP -Xroff does not treat indented lines specially. As such, indentation cannot be used to convey structure. +Lightroff does not treat indented lines specially. As such, indentation cannot be used to convey structure. diff --git a/README.x b/README.x deleted file mode 100644 index ea6bfc0..0000000 --- a/README.x +++ /dev/null @@ -1,62 +0,0 @@ -<!-- -*- mode: xroff; mode: olivetti -*- --> - - -<ss 12 0> -<nr PI 0> -<nr PD 0.5v> -<if n .nr PD 1v> -<de i>\\fI\\$*\\fR<.> -<de bi>\\f(BI\\$*\\fB<.> -<de cw>\\f(CW\\$*\\fR<.> -<de cwb>\\f(CB\\$*\\fR<.> - - -<TL><bi Xroff>, an alternative troff syntax -<AU>John Ankarstrm -<DA 10 June 2022> - - -<SH 1>Introduction -<LP><i Xroff> is an alternative syntax for troff, visually inspired by SGML/XML. It differs from troff's default syntax in the following ways: - -<IP 1. 3>Xroff requests begin with a less-than sign and end with a greater-than sign, e.g., <cw \<SH 1\>>. These symbols may be escaped with a backslash.* -<IP 2.>Xroff requests may be used inline. The following works as expected: <cw "(\<ft B\>bold\<ft R\>)">.** -<IP 3.>Xroff ignores empty lines. -<IP 4.>Default troff syntax may be used between <cw \<![> and <cw ]\>>. - -<LP>The similarities with XML end at the visual level. Unlike XML, xroff is unstructured and imperative. There is no concept of closing tags. - -<FS *>For comparison, default troff requests begin with a newline and a control character, usually a period or an apostrophe, and end with another newline.<FE> - -<FS **>Before an inline request, <cw xroff> automatically inserts a <cw \\\\c> escape when appropriate.<FE> - - -<SH 1>Example -<IP "" 3><nf><eo><![ -<de b>\\fB\\$*\\fR<.> - -<TL>Example document -<AU>John Doe - -<AB>Pellentesque dapibus suscipit ligula. Donec posuere augue in quam. -Etiam vel tortor sodales tellus ultricies commodo. Suspendisse -potenti. Aenean in sem ac leo mollis blandit. Donec neque quam, -dignissim in, mollis nec, sagittis eu, wisi.<AE> - -<SH 1>Introduction -<LP><b Nullam eu ante> vel est convallis dignissim. Fusce suscipit, -wisi nec facilisis facilisis, est dui fermentum leo, quis tempor -ligula erat quis odio. Nunc porta vulputate tellus. -]><ec> - - -<SH 1><cwb Xroff> -<PP>The program <cw xroff> translates xroff source to troff source. - - -<SH 1><cwb Xroff-mode> -<PP>For Emacs users, there is a major mode named <cw xroff-mode> that provides syntax highlighting for xroff source. To further improve the writing experience, I also recommend <cw olivetti-mode>. - - -<SH 1>Caveats -<LP>Xroff does not treat indented lines specially. As such, indentation cannot be used to convey structure. @@ -1,4 +1,4 @@ -;;; xroff.el --- major mode for xroff -*- lexical-binding: t; -*- +;;; lightroff.el --- major mode for lightroff -*- lexical-binding: t; -*- ;; Copyright (C) 2022 John Ankarström @@ -7,7 +7,7 @@ ;; Version: 0.1 ;; Keywords: troff groff -;; URL: http://ankarstrom.se/~john/etc/xroff +;; URL: http://ankarstrom.se/~john/etc/lightroff ;; This file is not part of GNU Emacs. @@ -16,20 +16,20 @@ ;;; Commentary: -;; Major mode for xroff, an alternative, XML-like syntax for troff. +;; Major mode for lightroff, an alternative, XML-like syntax for troff. ;;; Code: -(defvar xroff--request-regexp +(defvar lightroff--request-regexp (rx "<" (group (+ (or "\\>" (not (in "> "))))) (group (* (or "\\>" (not ?>)))) ">")) -(defvar xroff--single-escape-regexp +(defvar lightroff--single-escape-regexp (rx "\\" any)) -(defvar xroff--identifier-escape-regexp +(defvar lightroff--identifier-escape-regexp (rx "\\" (any "FfgkmnOsYZ*$") (? (any "+-")) @@ -37,50 +37,50 @@ (seq "(" any any) (seq "[" (* (not "]")) "]")))) -(defvar xroff--parameter-escape-regexp +(defvar lightroff--parameter-escape-regexp (rx "\\" (any "ABbCDHhLlMNoRSVvwXxz") "'" (* (not "'")) "'")) -(defconst xroff-font-lock-keywords +(defconst lightroff-font-lock-keywords `(;; Comment. ("<!--.*-->" (0 font-lock-comment-face)) ;; Request. - (,(concat xroff--request-regexp) + (,(concat lightroff--request-regexp) (1 font-lock-keyword-face keep) (2 font-lock-string-face keep)) - (,(concat "\\\\" xroff--request-regexp) + (,(concat "\\\\" lightroff--request-regexp) (1 nil t) (2 nil t)) ;; Parameter escape (e.g., \l'...'). - (,xroff--parameter-escape-regexp - (0 xroff-escape-face)) - (,(concat "\\\\" xroff--parameter-escape-regexp) + (,lightroff--parameter-escape-regexp + (0 lightroff-escape-face)) + (,(concat "\\\\" lightroff--parameter-escape-regexp) (0 nil t)) ;; Identifier escape (e.g., \n(PI). - (,xroff--identifier-escape-regexp - (0 xroff-escape-face)) - (,(concat "\\\\" xroff--identifier-escape-regexp) + (,lightroff--identifier-escape-regexp + (0 lightroff-escape-face)) + (,(concat "\\\\" lightroff--identifier-escape-regexp) (0 nil t)) ;; Single escape (e.g., \%). - (,xroff--single-escape-regexp - (0 xroff-escape-face)) - (,(concat "\\\\" xroff--single-escape-regexp) + (,lightroff--single-escape-regexp + (0 lightroff-escape-face)) + (,(concat "\\\\" lightroff--single-escape-regexp) (0 nil t)) ;; Escaped backslash. (,"\\\\\\\\" - (0 xroff-escape-face t)))) + (0 lightroff-escape-face t)))) -(defface xroff-escape +(defface lightroff-escape '((t (:foreground "gray"))) - "`xroff-mode' face used to highlight backslash escapes." - :group 'xroff) -(defvar xroff-escape-face 'xroff-escape) + "`lightroff-mode' face used to highlight backslash escapes." + :group 'lightroff) +(defvar lightroff-escape-face 'lightroff-escape) ;;;###autoload -(define-derived-mode xroff-mode text-mode "Xroff" - "Major mode for editing documents with xroff syntax." +(define-derived-mode lightroff-mode text-mode "Lightroff" + "Major mode for editing documents with lightroff syntax." ;; A start or end tag by itself on a line separates a paragraph. ;; This is desirable because SGML discards a newline that appears ;; immediately after a start tag or immediately before an end tag. @@ -93,11 +93,11 @@ (setq-local comment-end " -->") ;; (setq-local comment-indent-function 'sgml-comment-indent) ;; (setq-local comment-line-break-function 'sgml-comment-indent-new-line) - (setq-local font-lock-defaults '((xroff-font-lock-keywords))) + (setq-local font-lock-defaults '((lightroff-font-lock-keywords))) ;; (setq-local font-lock-multiline t) (setq-local comment-start-skip "<!--[ \t]*") (setq-local comment-end-skip "[ \t]*--[ \t\n]*>") (visual-line-mode 1)) -(provide 'xroff) -;;; xroff.el ends here +(provide 'lightroff) +;;; lightroff.el ends here diff --git a/xroff.lex b/lightroff.lex index 9326415..9326415 100644 --- a/xroff.lex +++ b/lightroff.lex |