File tree Expand file tree Collapse file tree 2 files changed +15
-7
lines changed
Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -640,9 +640,13 @@ pub fn get_title<'a>(root: &'a AstNode<'a>) -> anyhow::Result<String> {
640640 match & node. data . borrow ( ) . value {
641641 & NodeValue :: Heading ( ref header) => {
642642 if header. level == 1 {
643- let content = node
644- . first_child ( )
645- . ok_or ( anyhow:: anyhow!( "markdown heading has no child" ) ) ?;
643+ let content = match node. first_child ( ) {
644+ Some ( child) => child,
645+ None => {
646+ warn ! ( "markdown heading has no child" ) ;
647+ return Ok ( false ) ;
648+ }
649+ } ;
646650 match & content. data . borrow ( ) . value {
647651 & NodeValue :: Text ( ref text) => {
648652 title = Some ( text. to_owned ( ) ) ;
@@ -703,9 +707,13 @@ pub fn get_toc<'a>(root: &'a AstNode<'a>) -> anyhow::Result<Vec<TocLink>> {
703707 & NodeValue :: Heading ( ref header) => {
704708 header_counter += 1 ;
705709 if header. level != 1 {
706- let sibling = node
707- . first_child ( )
708- . ok_or ( anyhow:: anyhow!( "markdown heading has no child" ) ) ?;
710+ let sibling = match node. first_child ( ) {
711+ Some ( child) => child,
712+ None => {
713+ warn ! ( "markdown heading has no child" ) ;
714+ return Ok ( false ) ;
715+ }
716+ } ;
709717 match & sibling. data . borrow ( ) . value {
710718 & NodeValue :: Text ( ref text) => {
711719 links. push ( TocLink :: new ( text, header_counter - 1 ) . level ( header. level ) ) ;
Original file line number Diff line number Diff line change 55use crate::components::inputs::text::editable_header::{EditableHeader, Headers};
66use crate::components::stimulus::stimulus_target::StimulusTarget;
77use crate::components::stimulus::stimulus_action::StimulusAction;
8- use crate::components::stimulus::stimulus_action::StimulusEvents;
8+ // use crate::components::stimulus::stimulus_action::StimulusEvents;
99use crate::components::inputs::select::Select;
1010use crate::components::inputs::switch::Switch;
1111%>
You can’t perform that action at this time.
0 commit comments