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> {
640
640
match & node. data . borrow ( ) . value {
641
641
& NodeValue :: Heading ( ref header) => {
642
642
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
+ } ;
646
650
match & content. data . borrow ( ) . value {
647
651
& NodeValue :: Text ( ref text) => {
648
652
title = Some ( text. to_owned ( ) ) ;
@@ -703,9 +707,13 @@ pub fn get_toc<'a>(root: &'a AstNode<'a>) -> anyhow::Result<Vec<TocLink>> {
703
707
& NodeValue :: Heading ( ref header) => {
704
708
header_counter += 1 ;
705
709
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
+ } ;
709
717
match & sibling. data . borrow ( ) . value {
710
718
& NodeValue :: Text ( ref text) => {
711
719
links. push ( TocLink :: new ( text, header_counter - 1 ) . level ( header. level ) ) ;
Original file line number Diff line number Diff line change 5
5
use crate::components::inputs::text::editable_header::{EditableHeader, Headers};
6
6
use crate::components::stimulus::stimulus_target::StimulusTarget;
7
7
use crate::components::stimulus::stimulus_action::StimulusAction;
8
- use crate::components::stimulus::stimulus_action::StimulusEvents;
8
+ // use crate::components::stimulus::stimulus_action::StimulusEvents;
9
9
use crate::components::inputs::select::Select;
10
10
use crate::components::inputs::switch::Switch;
11
11
%>
You can’t perform that action at this time.
0 commit comments