Skip to content

Commit a775cbf

Browse files
authored
Update comrak to 0.49 (microsoft#720)
1 parent eb43870 commit a775cbf

4 files changed

Lines changed: 57 additions & 37 deletions

File tree

autorust/Cargo.lock

Lines changed: 43 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

autorust/codegen/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ heck = "0.5"
1717
regex = "1"
1818
indexmap = { version = "2", features = ["serde"] }
1919
path_abs = "0.5"
20-
comrak = "0.43"
20+
comrak = "0.49"
2121
serde = "1"
2222
http-types = "2"
2323
once_cell = "1"

autorust/codegen/src/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ heck = "0.5"
1717
regex = "1.7"
1818
indexmap = { version = "2.0", features = ["serde"] }
1919
path_abs = "0.5"
20-
comrak = "0.22"
20+
comrak = "0.49"
2121
serde = "1.0"
2222
http-types = "2.12"
2323
once_cell = "1.16"

autorust/codegen/src/config_parser.rs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ pub fn parse_configurations_from_autorest_config_file(
103103
mod literate_config {
104104
use super::*;
105105
use comrak::{
106-
nodes::{AstNode, NodeCode, NodeCodeBlock, NodeValue},
107-
parse_document, Arena, ComrakOptions,
106+
nodes::{AstNode, NodeCode, NodeValue},
107+
parse_document, Arena, Options,
108108
};
109109

110110
// Per the [Literage Configuration format](https://azure.github.io/autorest/user/literate-file-formats/configuration.html),
@@ -121,7 +121,7 @@ mod literate_config {
121121
/// [Literate Configuration](http://azure.github.io/autorest/user/literate-file-formats/configuration.html) [CommonMark](https://commonmark.org/) file.
122122
pub(crate) fn parse_configuration(cmark_content: &str) -> Result<Configuration> {
123123
let arena = Arena::new();
124-
let root = parse_document(&arena, cmark_content, &ComrakOptions::default());
124+
let root = parse_document(&arena, cmark_content, &Options::default());
125125

126126
// Get the AST node corresponding with "## Configuration".
127127
let configuration_heading_node =
@@ -186,8 +186,11 @@ mod literate_config {
186186
// from https://github.com/kivikakk/comrak/blob/main/examples/headers.rs
187187
fn collect_text<'a>(node: &'a AstNode<'a>, output: &mut String) {
188188
match node.data.borrow().value {
189-
NodeValue::Text(ref literal) | NodeValue::Code(NodeCode { ref literal, .. }) => {
190-
output.push_str(literal)
189+
NodeValue::Text(ref literal) => {
190+
output.push_str(literal.as_ref())
191+
}
192+
NodeValue::Code(NodeCode { ref literal, .. }) => {
193+
output.push_str(literal.as_ref())
191194
}
192195
NodeValue::LineBreak | NodeValue::SoftBreak => output.push(' '),
193196
_ => {
@@ -250,18 +253,12 @@ mod literate_config {
250253
)
251254
})?;
252255
loop {
253-
if let NodeValue::CodeBlock(NodeCodeBlock {
254-
info,
255-
literal,
256-
fenced,
257-
..
258-
}) = &current_node.data.borrow().value
259-
{
260-
if !fenced {
256+
if let NodeValue::CodeBlock(ref code_block) = &current_node.data.borrow().value {
257+
if !code_block.fenced {
261258
continue;
262259
}
263-
if info.trim_start().to_lowercase().starts_with("yaml") {
264-
return Ok(Some(literal.to_owned()));
260+
if code_block.info.trim_start().to_lowercase().starts_with("yaml") {
261+
return Ok(Some(code_block.literal.to_string()));
265262
}
266263
}
267264
current_node = current_node.next_sibling().ok_or_else(|| {

0 commit comments

Comments
 (0)