Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/abhinav/goldmark-wikilink
An extension for goldmark Markdown parser adding support for parsing and rendering wikilinks.
https://github.com/abhinav/goldmark-wikilink
golang markdown obsidian
Last synced: 26 days ago
JSON representation
An extension for goldmark Markdown parser adding support for parsing and rendering wikilinks.
- Host: GitHub
- URL: https://github.com/abhinav/goldmark-wikilink
- Owner: abhinav
- License: bsd-3-clause
- Created: 2021-03-15T02:14:48.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-11-25T03:18:33.000Z (about 2 months ago)
- Last Synced: 2024-12-09T13:12:48.784Z (about 1 month ago)
- Topics: golang, markdown, obsidian
- Language: Go
- Homepage: https://abhinav.github.io/goldmark-wikilink/
- Size: 101 KB
- Stars: 26
- Watchers: 3
- Forks: 7
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# goldmark-wikilink
[![Go Reference](https://pkg.go.dev/badge/go.abhg.dev/goldmark/wikilink.svg)](https://pkg.go.dev/go.abhg.dev/goldmark/wikilink)
[![CI](https://github.com/abhinav/goldmark-wikilink/actions/workflows/ci.yml/badge.svg)](https://github.com/abhinav/goldmark-wikilink/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/abhinav/goldmark-wikilink/branch/main/graph/badge.svg?token=W98KYF8SPE)](https://codecov.io/gh/abhinav/goldmark-wikilink)goldmark-wikilink is an extension for the [goldmark] Markdown parser that
supports parsing `[[...]]`-style wiki links
and `![[...]]`-style embedded wiki links.[goldmark]: http://github.com/yuin/goldmark
**Demo**:
A web-based demonstration of the extension is available at
.## Installation
```bash
go get go.abhg.dev/goldmark/wikilink@latest
```## Usage
To use goldmark-wikilink, import the `wikilink` package.
```go
import "go.abhg.dev/goldmark/wikilink"
```Then include the `wikilink.Extender` in the list of extensions
that you build your [`goldmark.Markdown`] with.[`goldmark.Markdown`]: https://pkg.go.dev/github.com/yuin/goldmark#Markdown
```go
goldmark.New(
goldmark.WithExtensions(
&wikilink.Extender{},
),
// ...
)
```## Link resolution
By default, wikilinks will be converted to URLs based on the page name,
unless they already have an extension.[[Foo]] => "Foo.html"
[[Foo bar]] => "Foo bar.html"
[[Foo.pdf]] => "Foo.pdf"
[[Foo.png]] => "Foo.png"You can change this by supplying a custom [`wikilink.Resolver`]
to your `wikilink.Extender` when you install it.[`wikilink.Resolver`]: https://pkg.go.dev/go.abhg.dev/goldmark/wikilink#Resolver
```go
goldmark.New(
goldmark.WithExtensions(
// ...
&wikilink.Extender{
Resolver: myresolver,
},
),
// ...
)
```## Embedding images
Use the embedded link form (`![[...]]`) to add images to a document.
![[foo.png]]
Add alt text to images with the `![[...|...]]` form:
![[foo.png|alt text]]