Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lexer and friends #61

Merged
merged 37 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d2377ae
new lexer
Lurk Sep 18, 2024
f90f405
new nodes
Lurk Sep 18, 2024
33b2929
new parser
Lurk Sep 18, 2024
d32c929
lib
Lurk Sep 18, 2024
33374b3
remove debug
Lurk Sep 20, 2024
bab5438
highlight must use bang instead of greater than
Lurk Sep 20, 2024
990609a
remove metadata node
Lurk Sep 20, 2024
8639bbf
add image doc
Lurk Sep 20, 2024
be0961f
move to serde adjacently tagged enum representation
Lurk Sep 20, 2024
ce307ab
nodes -> body
Lurk Sep 20, 2024
e2db683
derive Eq for yamd
Lurk Sep 20, 2024
c05ed68
images doc
Lurk Sep 20, 2024
39c5eb9
code doc
Lurk Sep 20, 2024
7f04a02
list doc
Lurk Sep 20, 2024
40aadeb
thematic break doc update
Lurk Sep 20, 2024
eec3305
embed doc
Lurk Sep 20, 2024
83962fd
collapsible doc
Lurk Sep 20, 2024
f48d099
MSRV update
Lurk Sep 23, 2024
bd68910
Simplify list parser
Lurk Sep 23, 2024
d9de300
fix embed without pipe
Lurk Sep 25, 2024
a7916ab
remove Debug implementation add more tests
Lurk Sep 25, 2024
faf62b4
even more tests
Lurk Sep 25, 2024
69a5ed3
test coverage for bold
Lurk Sep 25, 2024
63fd2ab
remove serialization to YAMD due to lack of tests
Lurk Sep 25, 2024
5f0919e
more tests
Lurk Sep 26, 2024
b88cbc8
fix list failed nested list case
Lurk Sep 26, 2024
34afeb8
use correct token
Lurk Sep 26, 2024
37bc912
heading test coverage
Lurk Sep 26, 2024
84f79e5
yamd test coverage
Lurk Sep 26, 2024
834fe16
token test coverage
Lurk Sep 26, 2024
05bdac8
remove Default implementation from Images
Lurk Sep 26, 2024
0c4c684
remove conversion to String
Lurk Sep 26, 2024
93a8dd6
paragraph test coverage
Lurk Sep 26, 2024
5d2c262
collapsible test coverage
Lurk Sep 27, 2024
21337f7
metadata test coverage
Lurk Sep 27, 2024
0e09b3b
advance_until refactoring
Lurk Sep 28, 2024
eee3666
try_range coverage
Lurk Sep 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
# https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
strategy:
matrix:
msrv: [1.67.1] #version at the moment of creation
msrv: [1.80.0] # due to Option::take_if usage
name: ubuntu / ${{ matrix.msrv }}
steps:
- uses: actions/checkout@v4
Expand Down
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[package]
name = "yamd"
version = "0.13.3"
description = "Yet Another Markdown Document (flavour)"
version = "0.14.0"
edition = "2021"
license = "MIT OR Apache-2.0"
description = "Yet Another Markdown Document (flavor)"
repository = "https://github.com/Lurk/yamd"
readme = "README.md"
keywords = ["markdown", "parser"]

[dependencies]
serde = { version = "1.0.197", features = ["derive"] }

[dev-dependencies]
pretty_assertions = "1.4.0"

[dependencies]
serde = { version = "1.0.197", features = ["derive"] }
chrono = { version = "0.4.37", features = ["serde"] }
serde_yaml = "0.9.34"

81 changes: 56 additions & 25 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,73 @@
# Yet another markdown document flavour (YAMD)
# yamd

[![codecov](https://codecov.io/gh/Lurk/yamd/branch/main/graph/badge.svg?token=F8KRUYI1AA)](https://codecov.io/gh/Lurk/yamd)
[![crates.io](https://img.shields.io/crates/v/yamd.svg)](https://crates.io/crates/yamd)
[![Released API docs](https://docs.rs/yamd/badge.svg)](https://docs.rs/yamd)

## Status
<!-- cargo-rdme start -->

YAMD - Yet Another Markdown Document (flavour)

Simplified version of [CommonMark](https://spec.commonmark.org/).

For formatting check YAMD struct documentation.

## Reasoning

Simplified set of rules allows to have simpler, more efficient, parser and renderer.
YAMD does not provide render functionality, instead it is a [serde]
serializable structure that allows you to write any renderer for that structure. All HTML
equivalents in this doc are provided as an example to what it can be rendered.

## Difference from CommonMark

### Escaping

Escaping done on a [lexer] level. Every symbol following the `\` symbol will be treated as a
literal.

Example:

| YAMD | HTML equivalent |
|-----------|-----------------|
| `\**foo**`|`<p>**foo**</p>` |

### Escape character

To get `\` - `\\` must be used.

Example:

It is not ready to poke around. There is significant API changes expected.
| YAMD | HTML equivalent |
|---------------|-----------------------|
| `\\**foo**` |`<p>\<b>foo</b></p>` |

## Why?

Initial idea was to create human readable text format for my blog. Why not existing flavour?
Existing flavours do not have elements like image gallery, dividers, highlight, etc.
### Precedence

## Features
[CommonMark](https://spec.commonmark.org/0.31.2/#precedence) defines container blocks and leaf
blocks. And that container block indicator has higher precedence. YAMD does not discriminate by
block type, every node (block) is the same. In practice, there are no additional rules to encode
and remember.

Deserialize markdown to YAMD struct, Serialize YAMD struct to markdown.
Example:

## Example
| YAMD | HTML equivalent |
|-----------------------|-----------------------------------------------|
| ``- `one\n- two` `` | `<ol><li><code>one\n- two</code></li></ol>` |

```rust
use yamd::{deserialize, serialize};
let input = r#"---
title: YAMD documnet showcase
date: 2023-08-13T15:42:00+02:00
preview: here is how you can serialize ande deserialize YAMD document
tags:
- yamd
- markdown
---

# This is a new Yamd document
If you want to have two ListItem's use escaping:

Check out [documentation](https://docs.rs/yamd/latest/yamd/) to get what elements **Yamd** format supports.
| YAMD | HTML equivalent |
|---------------------------|-------------------------------------------|
| ``- \`one\n- two\` `` | ``<ol><li>`one</li><li>two`</li><ol>`` |

"#;
let yamd = deserialize(input).unwrap();
let output = serialize(&yamd);
```
The reasoning is that those kind issues can be caught with tooling like linters/lsp. That tooling
does not exist yet.

### Nodes

List of supported [nodes](https://docs.rs/yamd/latest/yamd/nodes/) and their formatting slightly defers from CommonSpec.

<!-- cargo-rdme end -->
Loading
Loading