cosy
A parser for Cosense (formerly Scrapbox) markup syntax that produces a typed AST.
Installation
[]
= "0.1"
To enable JSON serialization of the AST via serde:
[]
= { = "0.1", = ["serde"] }
Usage
use ;
let doc = parse.unwrap;
for block in &doc
Custom syntax extensions
Implement CosyParserExtension to inject your own bracket syntax:
use CosyParserExtension;
;
let doc = parse.unwrap;
See examples/speech_bubble_extension.rs for a full example.
URL handling
Labeled links ([label https://...]) carry a parsed url::Url in
Link::WithLabel.href. cosy re-exports the Url type at its crate root for convenience:
use Url;
Supported syntax
Block-level
| Syntax | Description |
|---|---|
| (indented lines) | Nested bullet list |
code:filename |
Code block |
table:name |
Table |
> text |
Quote |
? query |
Helpfeel search query |
$ command % command |
Command-line notation (bash / csh) |
Inline
| Syntax | Description |
|---|---|
[Page Name] |
Internal page link |
[/project/page] |
Cross-project link |
[https://...] |
External URL |
[URL Label] |
Labeled link |
[image.png] |
Image (detected by MIME type) |
[img link] |
Linked image |
[name.icon] [name.icon*3] |
User icon |
`code` |
Inline code |
[$ expr] |
Math (LaTeX) |
[* bold] [/ italic] [- strike] |
Decoration |
[[text]] |
Strong (large bold) text |
[[image.png]] |
Strong (large) image |
[[https://...]] |
Strong (large) link |
[[name.icon]] |
Strong (large) icon |
#tag |
Hashtag |
[N35.xx,E139.xx] [N35.xx,E139.xx,Z14] |
Geographic coordinate (map embed) |
License
MIT — see LICENSE.