Crate somedoc

A very simple document model and markup generator.

MIT License Minimum Rust Version crates.io docs.rs Build Audit GitHub stars


Model

The somedoc::model module provides the model to construct documents.

Example

```rust fn readmemaker(cratename: &str, repoowner: &str, reponame: &str, headline: &str) -> Document { let tbd = Paragraph::plain_str("TBD"); let mut doc = Document::default();

doc.add_heading(Heading::heading_1(&format!("Crate {}", crate_name)))
    .add_paragraph(Paragraph::plain_str(headline));

let mut para = Paragraph::default();
para.add_image(Image::new(HyperLink::external_with_label_str(
    "https://img.shields.io/badge/license-mit-118811.svg",
    "MIT License",
)))
.add_image(Image::new(HyperLink::external_with_label_str(
    "https://img.shields.io/badge/Min%20Rust-1.40-green.svg",
    "Build",
)))
.add_image(Image::new(HyperLink::external_with_label_str(
    &format!(
        "https://github.com/{}/{}/workflows/Rust/badge.svg",
        repo_owner, repo_name
    ),
    "Minimum Rust Version",
)))
.add_image(Image::new(HyperLink::external_with_label_str(
    &format!(
        "https://github.com/{}/{}/workflows/Security%20audit/badge.svg",
        repo_owner, repo_name
    ),
    "Audit",
)));

doc.add_paragraph(para)
    .add_thematic_break()
    .add_paragraph(tbd.clone())
    .add_heading(Heading::heading_2("Example"))
    .add_paragraph(tbd.clone())
    .add_heading(Heading::heading_2("Features"))
    .add_paragraph(tbd.clone())
    .add_thematic_break()
    .add_heading(Heading::heading_2("Changes"))
    .add_paragraph(Paragraph::bold_str("Version 0.1.0"));

let mut list = List::default();
list.add_item_from(Span::plain_str("Initial release.").into());

doc.add_list(list)
    .add_heading(Heading::heading_2("Issues"))
    .add_paragraph(tbd.clone());

doc

}

```

Writers

The somedoc::write module contains a number of serializers that generate specific markup formats for different platforms. So far, this includes HTML, LaTeX, and Markdown of different flavors.

JSON Interchange

A JSON representation of the library's Document structure is also provided and can be read as well as written to allow for tool interchange.

Example

The following writes a constructed document to stdout as a Markdown document. The default flavor supported by the writer is the CommonMark spec.

```rust use somedoc::write::writedocumentto_string; use somedoc::write::markdown::MarkdownFlavor;

let doc = makesomedocument();

let docstr = writedocumenttostring(&doc, MarkdownFlavor::default().into()).unwrap(); println!("{}", doc_str); ```

The following writes the same document out in the XWiki markup form.

```rust use somedoc::write::{writedocumentto_string, OutputFormat};

let doc = makesomedocument();

let docstr = writedocumenttostring(&doc, OutputFormat::XWiki).unwrap(); println!("{}", doc_str); ```


Changes

Version 0.2.4

Version 0.2.3

Version 0.2.2

Version 0.2.1

This is a significant update, some APIs will have changed, but the plan is that these new API forms will be stabilized toward a 0.3.0 release that can be relied on for non-breaking changes.

Version 0.2.0

Version 0.1.7

Version 0.1.6

Version 0.1.5 (not published)

Version 0.1.4

Version 0.1.3

Version 0.1.2

Version 0.1.1

Version 0.1.0

TODO