diff options
Diffstat (limited to 'src/generator/pandoc.rs')
-rw-r--r-- | src/generator/pandoc.rs | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/generator/pandoc.rs b/src/generator/pandoc.rs index 1753d34..035acab 100644 --- a/src/generator/pandoc.rs +++ b/src/generator/pandoc.rs | |||
@@ -1,14 +1,11 @@ | |||
1 | use super::config::Config; | 1 | use super::config::Config; |
2 | use crate::types::Entity; | 2 | use crate::types::*; |
3 | 3 | ||
4 | use pandoc_types::definition::{Attr, Block, Inline, Meta, MetaValue, Pandoc}; | 4 | use pandoc_types::definition::{Attr, Block, Inline, Meta, MetaValue, Pandoc}; |
5 | 5 | ||
6 | use std::collections::BTreeMap; | 6 | use std::collections::BTreeMap; |
7 | 7 | ||
8 | pub(crate) fn into_pandoc( | 8 | pub(crate) fn into_pandoc(entity: Entity, config: &Config) -> (Pandoc, BTreeMap<EntityId, Entity>) { |
9 | entity: Entity, | ||
10 | config: &Config, | ||
11 | ) -> (Pandoc, BTreeMap<String, Entity>) { | ||
12 | let mut meta = Meta::null(); | 9 | let mut meta = Meta::null(); |
13 | 10 | ||
14 | let title = vec![Inline::Code(Attr::null(), entity.name.clone())]; | 11 | let title = vec![Inline::Code(Attr::null(), entity.name.clone())]; |
@@ -57,7 +54,7 @@ pub(crate) fn into_pandoc( | |||
57 | content.push(Block::Header( | 54 | content.push(Block::Header( |
58 | 2, | 55 | 2, |
59 | Attr::null(), | 56 | Attr::null(), |
60 | vec![Inline::Str(String::from(section_name))], | 57 | vec![Inline::Str(section_name.0.clone())], |
61 | )); | 58 | )); |
62 | 59 | ||
63 | content.push(members_list); | 60 | content.push(members_list); |
@@ -71,7 +68,7 @@ pub(crate) fn into_pandoc( | |||
71 | content.push(Block::Header( | 68 | content.push(Block::Header( |
72 | 2, | 69 | 2, |
73 | Attr::null(), | 70 | Attr::null(), |
74 | vec![Inline::Str(section_name.clone())], | 71 | vec![Inline::Str(section_name.0.clone())], |
75 | )); | 72 | )); |
76 | 73 | ||
77 | content.push(members_list); | 74 | content.push(members_list); |
@@ -79,7 +76,7 @@ pub(crate) fn into_pandoc( | |||
79 | embedded_documentation.push(Block::Header( | 76 | embedded_documentation.push(Block::Header( |
80 | 2, | 77 | 2, |
81 | Attr::null(), | 78 | Attr::null(), |
82 | vec![Inline::Str(section_name + " Documentation")], | 79 | vec![Inline::Str(section_name.0 + " Documentation")], |
83 | )); | 80 | )); |
84 | 81 | ||
85 | for (_id, child) in children { | 82 | for (_id, child) in children { |
@@ -112,7 +109,7 @@ fn str_block(content: String) -> Block { | |||
112 | Block::Plain(vec![Inline::Str(content)]) | 109 | Block::Plain(vec![Inline::Str(content)]) |
113 | } | 110 | } |
114 | 111 | ||
115 | fn entity_link(id: &str, name: String) -> Inline { | 112 | fn entity_link(id: &EntityId, name: String) -> Inline { |
116 | use pandoc_types::definition::Target; | 113 | use pandoc_types::definition::Target; |
117 | use percent_encoding::{utf8_percent_encode, AsciiSet, CONTROLS}; | 114 | use percent_encoding::{utf8_percent_encode, AsciiSet, CONTROLS}; |
118 | 115 | ||
@@ -135,7 +132,7 @@ fn entity_link(id: &str, name: String) -> Inline { | |||
135 | vec![Inline::Code(Attr::null(), name)], | 132 | vec![Inline::Code(Attr::null(), name)], |
136 | Target( | 133 | Target( |
137 | once("./") | 134 | once("./") |
138 | .chain(utf8_percent_encode(id, FRAGMENT)) | 135 | .chain(utf8_percent_encode(&id.0, FRAGMENT)) |
139 | .collect(), | 136 | .collect(), |
140 | String::new(), | 137 | String::new(), |
141 | ), | 138 | ), |
@@ -147,7 +144,7 @@ fn raw_markdown(text: String) -> Block { | |||
147 | Block::RawBlock(Format(String::from("markdown")), text) | 144 | Block::RawBlock(Format(String::from("markdown")), text) |
148 | } | 145 | } |
149 | 146 | ||
150 | fn member_list<'a>(members: impl IntoIterator<Item = (&'a String, &'a Entity)>) -> Option<Block> { | 147 | fn member_list<'a>(members: impl IntoIterator<Item = (&'a EntityId, &'a Entity)>) -> Option<Block> { |
151 | let definitions: Vec<(Vec<Inline>, Vec<Vec<Block>>)> = members | 148 | let definitions: Vec<(Vec<Inline>, Vec<Vec<Block>>)> = members |
152 | .into_iter() | 149 | .into_iter() |
153 | .map(|(id, entity)| { | 150 | .map(|(id, entity)| { |