Compare commits
2 Commits
7d51aaa9a4
...
bf14fd5e04
Author | SHA1 | Date | |
---|---|---|---|
bf14fd5e04 | |||
228c3f3914 |
68
README
68
README
@ -185,6 +185,11 @@ An improved replacement for autocutsel in selection synchronization "mode":
|
|||||||
|
|
||||||
Only UTF8_STRING-convertible selections are synchronized.
|
Only UTF8_STRING-convertible selections are synchronized.
|
||||||
|
|
||||||
|
hasp -- (lib)asciidoc syntax preprocessor
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
Provisional tool to make libasciidoc understand more syntax, namely two-line/
|
||||||
|
underlined titles for my Gitea projects.
|
||||||
|
|
||||||
ht -- terminal emulator
|
ht -- terminal emulator
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Similar scope to st(1). Clever display of internal padding for better looks.
|
Similar scope to st(1). Clever display of internal padding for better looks.
|
||||||
@ -204,6 +209,35 @@ https://godoc.org/github.com/gorilla/websocket
|
|||||||
The higher-level client-server API could be made rather generic to allow for
|
The higher-level client-server API could be made rather generic to allow for
|
||||||
smooth integration with non-IRC "backends" such as Slack or Mattermost.
|
smooth integration with non-IRC "backends" such as Slack or Mattermost.
|
||||||
|
|
||||||
|
he -- text editor
|
||||||
|
~~~~~~~~~~~~~~~~~
|
||||||
|
VIM controls, no scripting, no syntax highlight, single-file, made for variable-
|
||||||
|
-width/proportional fonts. Initially done primarily to produce a text editing
|
||||||
|
widget, which is going to be an interesting challenge, arguably better solved by
|
||||||
|
whole program composition. Scintilla may provide some inspiration.
|
||||||
|
|
||||||
|
In the second stage, support for the Language Server Protocol will be added so
|
||||||
|
that the project can be edited using its own tools. Some scripting, perhaps
|
||||||
|
a tiny subset of VimL, might be desirable. Or other means of configuration.
|
||||||
|
|
||||||
|
Visual block mode or the color column may still be implemented.
|
||||||
|
|
||||||
|
The real model for the editor is Qt Creator with FakeVIM, though this is not to
|
||||||
|
be a clone of it, e.g. the various "Output" lists could be just special buffers,
|
||||||
|
which may be have names starting on "// ".
|
||||||
|
|
||||||
|
Resources:
|
||||||
|
- http://doc.cat-v.org/plan_9/4th_edition/papers/sam/
|
||||||
|
|
||||||
|
ho -- all-powerful organizer
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
Zettelkasten with fulltext search, arbitrary reciprocal links, arbitrary tags.
|
||||||
|
Flat storage. Should be able to use translation dictionaries for search hints.
|
||||||
|
|
||||||
|
Indexing and search may be based on a common database, no need to get all fancy:
|
||||||
|
http://rachbelaid.com/postgres-full-text-search-is-good-enough/
|
||||||
|
https://www.sqlite.org/fts3.html#full_text_index_queries (FTS4 seems better)
|
||||||
|
|
||||||
htd -- translation dictionary
|
htd -- translation dictionary
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
This specific kind of application doesn't need a lot of user interface either,
|
This specific kind of application doesn't need a lot of user interface either,
|
||||||
@ -230,26 +264,6 @@ hiv -- image viewer
|
|||||||
JPG, PNG, first frame of GIF. Zoom. Going through adjacent files in directory
|
JPG, PNG, first frame of GIF. Zoom. Going through adjacent files in directory
|
||||||
using cursor keys. Possibly a dialog with image metadata.
|
using cursor keys. Possibly a dialog with image metadata.
|
||||||
|
|
||||||
he -- text editor
|
|
||||||
~~~~~~~~~~~~~~~~~
|
|
||||||
VIM controls, no scripting, no syntax highlight, single-file, made for variable-
|
|
||||||
-width/proportional fonts. Initially done primarily to produce a text editing
|
|
||||||
widget, which is going to be an interesting challenge, arguably better solved by
|
|
||||||
whole program composition. Scintilla may provide some inspiration.
|
|
||||||
|
|
||||||
In the second stage, support for the Language Server Protocol will be added so
|
|
||||||
that the project can be edited using its own tools. Some scripting, perhaps
|
|
||||||
a tiny subset of VimL, might be desirable. Or other means of configuration.
|
|
||||||
|
|
||||||
Visual block mode or the color column may still be implemented.
|
|
||||||
|
|
||||||
The real model for the editor is Qt Creator with FakeVIM, though this is not to
|
|
||||||
be a clone of it, e.g. the various "Output" lists could be just special buffers,
|
|
||||||
which may be have names starting on "// ".
|
|
||||||
|
|
||||||
Resources:
|
|
||||||
- http://doc.cat-v.org/plan_9/4th_edition/papers/sam/
|
|
||||||
|
|
||||||
hfm -- file manager
|
hfm -- file manager
|
||||||
~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~
|
||||||
All we need to achieve here is replace Midnight Commander, which besides the
|
All we need to achieve here is replace Midnight Commander, which besides the
|
||||||
@ -263,14 +277,14 @@ Eventually the number of panels should be arbitrary with proper shortcuts for
|
|||||||
working with them. We might also integrate a special view for picture previews,
|
working with them. We might also integrate a special view for picture previews,
|
||||||
which might or might not deserve its own program.
|
which might or might not deserve its own program.
|
||||||
|
|
||||||
ho -- all-powerful organizer
|
hss -- spreadsheets
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~
|
||||||
Zettelkasten with fulltext search, arbitrary reciprocal links, arbitrary tags.
|
The first version doesn't need to be able to reference other cells, and can more
|
||||||
Flat storage. Should be able to use translation dictionaries for search hints.
|
or less be a CSV editor.
|
||||||
|
|
||||||
Indexing and search may be based on a common database, no need to get all fancy:
|
We can take inspiration from Excel:
|
||||||
http://rachbelaid.com/postgres-full-text-search-is-good-enough/
|
https://docs.microsoft.com/en-us/office/client-developer/excel/excel-recalculation
|
||||||
https://www.sqlite.org/fts3.html#full_text_index_queries (FTS4 seems better)
|
https://www.microsoft.com/en-us/research/uploads/prod/2018/03/build-systems.pdf
|
||||||
|
|
||||||
The rest
|
The rest
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
|
91
hasp/main.go
Normal file
91
hasp/main.go
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
// Program hasp is a preprocessor for libasciidoc to make it understand
|
||||||
|
// two-line/underlined titles, intended to be used in Gitea.
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"context"
|
||||||
|
"encoding/xml"
|
||||||
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
"unicode"
|
||||||
|
"unicode/utf8"
|
||||||
|
|
||||||
|
"github.com/bytesparadise/libasciidoc"
|
||||||
|
"github.com/bytesparadise/libasciidoc/pkg/renderer"
|
||||||
|
)
|
||||||
|
|
||||||
|
// isTitle returns the title level if the lines seem to form a title,
|
||||||
|
// zero otherwise. Input lines may inclide trailing newlines.
|
||||||
|
func isTitle(line1, line2 []byte) int {
|
||||||
|
// This is a very naïve method, we should target graphemes (thus at least
|
||||||
|
// NFC normalize the lines first) and account for wide characters.
|
||||||
|
diff := utf8.RuneCount(line1) - utf8.RuneCount(line2)
|
||||||
|
if len(line2) < 2 || diff < -1 || diff > 1 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// "Don't be fooled by back-to-back delimited blocks."
|
||||||
|
// Still gets fooled by other things, though.
|
||||||
|
if bytes.IndexFunc(line1, func(r rune) bool {
|
||||||
|
return unicode.IsLetter(r) || unicode.IsNumber(r)
|
||||||
|
}) < 0 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// The underline must be homogenous.
|
||||||
|
for _, r := range bytes.TrimRight(line2, "\r\n") {
|
||||||
|
if r != line2[0] {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1 + strings.IndexByte("=-~^+", line2[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
func writeLine(w *io.PipeWriter, cur, next []byte) []byte {
|
||||||
|
if level := isTitle(cur, next); level > 0 {
|
||||||
|
w.Write(append(bytes.Repeat([]byte{'='}, level), ' '))
|
||||||
|
next = nil
|
||||||
|
}
|
||||||
|
w.Write(cur)
|
||||||
|
return next
|
||||||
|
}
|
||||||
|
|
||||||
|
// ConvertTitles converts AsciiDoc two-line (underlined) titles to single-line.
|
||||||
|
func ConvertTitles(w *io.PipeWriter, input []byte) {
|
||||||
|
var last []byte
|
||||||
|
for _, cur := range bytes.SplitAfter(input, []byte{'\n'}) {
|
||||||
|
last = writeLine(w, last, cur)
|
||||||
|
}
|
||||||
|
writeLine(w, last, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
input, err := ioutil.ReadAll(os.Stdin)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
pr, pw := io.Pipe()
|
||||||
|
go func() {
|
||||||
|
defer pw.Close()
|
||||||
|
ConvertTitles(pw, input)
|
||||||
|
}()
|
||||||
|
|
||||||
|
// io.Copy(os.Stdout, pr)
|
||||||
|
// return
|
||||||
|
|
||||||
|
_, err = libasciidoc.ConvertToHTML(context.Background(), pr, os.Stdout,
|
||||||
|
renderer.IncludeHeaderFooter(true))
|
||||||
|
if err != nil {
|
||||||
|
// Fallback: output all the text sanitized for direct inclusion.
|
||||||
|
os.Stdout.WriteString("<pre>")
|
||||||
|
for _, line := range bytes.Split(input, []byte{'\n'}) {
|
||||||
|
xml.EscapeText(os.Stdout, line)
|
||||||
|
os.Stdout.WriteString("\n")
|
||||||
|
}
|
||||||
|
os.Stdout.WriteString("</pre>")
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user