1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
//! Turns Gemtext into idiomatic HTML.
//!
//! ```rust
//! let document = "# Hello, world!";
//! let output = gemrendr::html_from_gemtext(document, Default::default());
//! assert!(output.ends_with("<h1>Hello, world!</h1>"));
//! ```
//!
//! By default, the output includes a comment that points to gemrendr's
//! public source code repository. To omit this line, configure render
//! options like so:
//! ```rust
//! use gemrendr::{RenderOptions, html_from_gemtext};
//!
//! let options = RenderOptions {
//! preamble: false,
//! ..Default::default()
//! };
//! let document = "# Hello, world!";
//! let output = html_from_gemtext(document, options);
//! assert_eq!(output, "<h1>Hello, world!</h1>");
//! ```
//!
//! See [`RenderOptions`] for more available options.
//!
//! To only parse the gemtext, without transforming it right away into an HTML string,
//! use the various `parse` methods on [`gemtext::Document`]:
//! ```rust
//! use gemrendr::gemtext::Document;
//! # use gemrendr::gemtext::{GemtextContentBlock, HeadingLevel};
//!
//! let parsed = Document::parse_from_gemtext("# Hello, world!");
//! # assert_eq!(parsed.contents.len(), 1);
//! # assert_eq!(*parsed.contents.first().unwrap(), GemtextContentBlock::Heading { level: HeadingLevel::One, content: String::from("Hello, world!") });
//! let also_parsed = "# Hello, world!".parse::<Document>().unwrap();
//! # assert_eq!(also_parsed, parsed);
//! ```
//! With this representation you can, for example, do additional processing to determine
//! the page title (e.g. by considering first headings). To convert the parsed document
//! data into HTML, use [`Document::into_html`]:
//! ```rust
//! use gemrendr::gemtext::Document;
//!
//! let parsed = Document::parse_from_gemtext("# Hello, world!");
//! /* do something with parsed */
//! let output = parsed.into_html(Default::default());
//! assert!(output.into_string().ends_with("<h1>Hello, world!</h1>"));
//! ```
//!
//! ## Crate Features
// Copyright (C) 2025 AverageHelper
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
extern crate alloc;
extern crate core;
use String;
use ;
use Document;
pub use ;
use ;
/// Options to use when rendering Gemtext as HTML.
///
/// Because the addition of new future options is NOT considered a semver-major
/// breaking change, constructing this value directly may result in unexpected
/// compilation errors unless you use [`Default::default`] and the
/// "spread" syntax.
///
/// # Example
/// ```rust
/// # use gemrendr::{CopyButtonStyle, EmptyLineTag, RenderOptions};
/// let options = RenderOptions {
/// empty_line_tag: EmptyLineTag::P,
/// ..Default::default()
/// };
///
/// assert!(matches!(options.copy_button_style, CopyButtonStyle::None));
/// ```
/// Transforms the given Gemtext document string into an HTML document string.