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

Add nested fragments #12

Merged
merged 6 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ unique within your project and valid in the source file you're annotating. (The
added to the "safe" list in the future. If a character you want to use is not listed here, please
file an issue on GitHub (or better yet, send a PR)!

Fragments can also be nested. This is particularly useful when you want to annotate a region of a source file that is already contained within a larger "outer" fragment. The annotations for the "inner" fragment will not appear in the output. This is best illustrated with an example. See the following [source](./examples/test/nested.rs), [prose](./examples/test/nested.md) and [output](./examples/reference/test/nested.md) files.

### Referencing annotations

In order to insert a fragment in another file, add a line containing the symbol `@@` followed by the
Expand Down Expand Up @@ -149,10 +151,10 @@ the right.)_

- [@nickpascucci](https://github.com/nickpascucci/)
- [@karlicoss](https://github.com/karlicoss/)
- [@elidhu](https://github.com/elidhu/)

## Future Work

- Add support for allow overlapping fragments.
- Add support for custom formatting of annotation properties within the woven output.
- Paralellize file processing in Verso, and both reading from `stdin` and file reading in Recto.
- Add `--fragments-from` option to specify a source other than stdin for fragments.
4 changes: 2 additions & 2 deletions examples/check-examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ set -e

DIFF=$(which colordiff || echo "diff")

SOURCE_FILES="example.py test/example-2.py"
PROSE_FILES="empty.md example.md test/example-2.md test/level-2/l2.md"
SOURCE_FILES="example.py test/example-2.py test/nested.rs"
PROSE_FILES="empty.md example.md test/example-2.md test/level-2/l2.md test/nested.md"
OUTPUT_DIRECTORY=out

cd "$(dirname "$0")/.."
Expand Down
22 changes: 22 additions & 0 deletions examples/out/test/nested.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Out

## See the `main fn`

```rust
// test/nested.rs

fn main() {
let stdout = stdout();
let message = String::from("Hello fellow Rustaceans!");
let width = message.chars().count();

let mut writer = BufWriter::new(stdout.lock());
say(&message, width, &mut writer).unwrap();
}
```

## Take note of this special line

```rust
let message = String::from("Hello fellow Rustaceans!");
```
22 changes: 22 additions & 0 deletions examples/reference/test/nested.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Out

## See the `main fn`

```rust
// test/nested.rs

fn main() {
let stdout = stdout();
let message = String::from("Hello fellow Rustaceans!");
let width = message.chars().count();

let mut writer = BufWriter::new(stdout.lock());
say(&message, width, &mut writer).unwrap();
}
```

## Take note of this special line

```rust
let message = String::from("Hello fellow Rustaceans!");
```
15 changes: 15 additions & 0 deletions examples/test/nested.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Out

## See the `main fn`

```rust
// @?mainfn.file

@@mainfn
```

## Take note of this special line

```rust
@@mainfnmessage
```
15 changes: 15 additions & 0 deletions examples/test/nested.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use ferris_says::say;
use std::io::{stdout, BufWriter};

// @<mainfn
fn main() {
let stdout = stdout();
// @<mainfnmessage
let message = String::from("Hello fellow Rustaceans!");
// >@
let width = message.chars().count();

let mut writer = BufWriter::new(stdout.lock());
say(&message, width, &mut writer).unwrap();
}
// >@
Loading