parent
ed88fea76d
commit
b9f94aafed
2 changed files with 13 additions and 52 deletions
45
README.org
45
README.org
|
@ -1,44 +1,5 @@
|
||||||
* go-org
|
* go-org-orgwiki
|
||||||
An Org mode parser and static site generator in go.
|
|
||||||
Take a look at github pages
|
|
||||||
- for [[https://niklasfasching.github.io/go-org/][org to html conversion]] examples
|
|
||||||
- for a [[https://niklasfasching.github.io/go-org/blorg][static site]] generated by blorg
|
|
||||||
- to [[https://niklasfasching.github.io/go-org/convert.html][try it out live]] in your browser
|
|
||||||
|
|
||||||
[[https://raw.githubusercontent.com/niklasfasching/go-org/master/etc/example.png]]
|
Thanks to: [[https://github.com/niklasfasching/go-org][go-org]]
|
||||||
|
|
||||||
Please note
|
This fork is used exclusively by [[https://git.fz0x1.wtf/fz0x1/orgwiki][orgwiki]] and includes a few minor modifications tailored for it.
|
||||||
- the goal for the html export is to produce sensible html output, not to exactly reproduce the output of =org-html-export=.
|
|
||||||
- the goal for the parser is to support a reasonable subset of Org mode. Org mode is *huge* and I like to follow the 80/20 rule.
|
|
||||||
* usage
|
|
||||||
** command line
|
|
||||||
#+begin_src bash
|
|
||||||
$ go-org
|
|
||||||
Usage: go-org COMMAND [ARGS]...
|
|
||||||
Commands:
|
|
||||||
- render [FILE] FORMAT
|
|
||||||
FORMAT: org, html, html-chroma
|
|
||||||
Instead of specifying a file, org mode content can also be passed on stdin
|
|
||||||
- blorg
|
|
||||||
- blorg init
|
|
||||||
- blorg build
|
|
||||||
- blorg serve
|
|
||||||
#+end_src
|
|
||||||
** as a library
|
|
||||||
see [[https://github.com/niklasfasching/go-org/blob/master/main.go][main.go]] and hugo [[https://github.com/gohugoio/hugo/blob/master/markup/org/convert.go][org/convert.go]]
|
|
||||||
* development
|
|
||||||
1. =make setup=
|
|
||||||
2. change things
|
|
||||||
3. =make preview= (regenerates fixtures & shows output in a browser)
|
|
||||||
|
|
||||||
in general, have a look at the Makefile - it's short enough.
|
|
||||||
* resources
|
|
||||||
- test files
|
|
||||||
- [[https://raw.githubusercontent.com/kaushalmodi/ox-hugo/master/test/site/content-org/all-posts.org][ox-hugo all-posts.org]]
|
|
||||||
- https://ox-hugo.scripter.co/doc/examples/
|
|
||||||
- https://orgmode.org/manual/
|
|
||||||
- https://orgmode.org/worg/dev/org-syntax.html
|
|
||||||
- https://code.orgmode.org/bzg/org-mode/src/master/lisp/org.el
|
|
||||||
- https://code.orgmode.org/bzg/org-mode/src/master/lisp/org-element.el
|
|
||||||
- mostly those & ox-html.el, but yeah, all of [[https://code.orgmode.org/bzg/org-mode/src/master/lisp/]]
|
|
||||||
- existing Org mode implementations: [[https://github.com/emacsmirror/org][org]], [[https://github.com/bdewey/org-ruby/blob/master/spec/html_examples][org-ruby]], [[https://github.com/chaseadamsio/goorgeous/][goorgeous]], [[https://github.com/jgm/pandoc/][pandoc]]
|
|
||||||
|
|
|
@ -393,16 +393,16 @@ func (w *HTMLWriter) WriteRegularLink(l RegularLink) {
|
||||||
if l.Protocol == "file" {
|
if l.Protocol == "file" {
|
||||||
url = url[len("file:"):]
|
url = url[len("file:"):]
|
||||||
}
|
}
|
||||||
if isRelative := l.Protocol == "file" || l.Protocol == ""; isRelative && w.PrettyRelativeLinks {
|
// if isRelative := l.Protocol == "file" || l.Protocol == ""; isRelative && w.PrettyRelativeLinks {
|
||||||
if !strings.HasPrefix(url, "/") {
|
// if !strings.HasPrefix(url, "/") {
|
||||||
url = "../" + url
|
// url = "../" + url
|
||||||
}
|
// }
|
||||||
if strings.HasSuffix(url, ".org") {
|
// if strings.HasSuffix(url, ".org") {
|
||||||
url = strings.TrimSuffix(url, ".org") + "/"
|
// url = strings.TrimSuffix(url, ".org") + "/"
|
||||||
}
|
// }
|
||||||
} else if isRelative && strings.HasSuffix(url, ".org") {
|
// } else if isRelative && strings.HasSuffix(url, ".org") {
|
||||||
url = strings.TrimSuffix(url, ".org") + ".html"
|
// url = strings.TrimSuffix(url, ".org") + ".html"
|
||||||
}
|
// }
|
||||||
if prefix := w.document.Links[l.Protocol]; prefix != "" {
|
if prefix := w.document.Links[l.Protocol]; prefix != "" {
|
||||||
if tag := strings.TrimPrefix(l.URL, l.Protocol+":"); strings.Contains(prefix, "%s") || strings.Contains(prefix, "%h") {
|
if tag := strings.TrimPrefix(l.URL, l.Protocol+":"); strings.Contains(prefix, "%s") || strings.Contains(prefix, "%h") {
|
||||||
url = html.EscapeString(strings.ReplaceAll(strings.ReplaceAll(prefix, "%s", tag), "%h", u.QueryEscape(tag)))
|
url = html.EscapeString(strings.ReplaceAll(strings.ReplaceAll(prefix, "%s", tag), "%h", u.QueryEscape(tag)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue