| Crates.io | somedoc |
| lib.rs | somedoc |
| version | 0.2.10 |
| created_at | 2020-11-06 18:51:18.586591+00 |
| updated_at | 2021-05-18 19:38:53.130351+00 |
| description | A very simple document model and markup generator. |
| homepage | |
| repository | https://github.com/johnstonskj/rust-somedoc.git |
| max_upload_size | |
| id | 309309 |
| size | 420,643 |
A very simple document model and markup generator.
The somedoc::model module provides the model to construct documents.
fn readme_maker(crate_name: &str, repo_owner: &str, repo_name: &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
}
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.
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.
The following writes a constructed document to stdout as a Markdown document. The default flavor supported by
the writer is the CommonMark spec.
use somedoc::write::write_document_to_string;
use somedoc::write::markdown::MarkdownFlavor;
let doc = make_some_document();
let doc_str = write_document_to_string(&doc, MarkdownFlavor::default().into()).unwrap();
println!("{}", doc_str);
The following writes the same document out in the XWiki markup form.
use somedoc::write::{write_document_to_string, OutputFormat};
let doc = make_some_document();
let doc_str = write_document_to_string(&doc, OutputFormat::XWiki).unwrap();
println!("{}", doc_str);
Version 0.2.10
Added: use basic HTML output for tables in CommonMark.
Version 0.2.9
Fixed: using id macro for anchors in XWiki output.
Version 0.2.8
Fixed: trailing '|' removed from table rows for XWiki output.
Version 0.2.7
to_string and from_str functionality for OutputFormat.
OutputFormat now delegates the addition, and parsing, of flavors.Version 0.2.6
Image to have path/inner and alt_text fields.
Image.Label::copy_from constructor.math and add_math functions from HasInlineContent.Into<BlockContent> for Math.Version 0.2.5
math and add_math functions for HasBlockContent trait.FrontMatter enum for generated tables of content.Span.Version 0.2.4
\ref commands for internal references.id attributes for labels.Label::is_valid matching spaces.Version 0.2.3
fmt_json.serde and serde_json.version field to the Document to allow for tool checking, this will be the crate version on write.Serialize/Deserialize for SerdeVersion 0.2.2
inner_impl macro for consistent use of inner and into_inner methods.
link to inner on Image.From and from implementations on inline content.label to text on model::block::table::Column.Captioned trait to HasCaption for consistency.Text with Caption as type for HyperLink caption; implemented
HasCaption also.String.From<> instead in Caption, Code,
Formatted, Heading, Image.new_with_ functions to simply with_.ParagraphStyle, made alignment a single value property on Paragraph.
Paragraph and table::Column.HasAlignment trait (and macro) for consistency between paragraph and column.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.
fmt_html, fmt_latex, fmt_markdown`,
etc. with the default feature including all of these.Writer, and ConfigurableWriter to the write module to capture the
instantiation of a writer struct.Anchor type to a new Label, it is no longer a stand-alone inline
value, but has been added as a property to most block types.Abstract out of the Metadata enum and made it a property of the document
proper. This also affects the visitor API.label/alt_text on HyperLink to caption.Result<> where it wasn't needed.log.pretty_assertions for better comparison of test failures.Version 0.2.0
XWiki writer to use it.Math (inline), and MathBlock (block) constructs.Caption type and implementation for Code, MathBlock, and Table.Deref for some String newtypes (Anchor, Caption, Emoji, and Text).proptest for the String newtypes listed above.Version 0.1.7
Version 0.1.6
model::inline::emoji_names module, but only enabled for emoji_names feature.readme_maker example, this is used in the README and lib.rs documentation.write_code function.TextStyle -> SpanStyle, added Sized variant.read module as it was currently empty.model::visitor module, too many changes to stabilize yet.Version 0.1.5 (not published)
Version 0.1.4
Anchor into each writer.Version 0.1.3
Formatted alongside CodeBlock.Version 0.1.2
Version 0.1.1
Version 0.1.0