@@ -280,8 +280,9 @@ enter(CompileContext1 = #markdown_mdast_compile_context{events = Events, index =
280280 on_enter_hard_break (CompileContext1 );
281281 hard_break_trailing ->
282282 on_enter_hard_break (CompileContext1 );
283- % %% on_enter_heading
284- % heading_atx -> on_enter_heading(CompileContext1);
283+ % % on_enter_heading
284+ heading_atx ->
285+ on_enter_heading (CompileContext1 );
285286 % heading_setext -> on_enter_heading(CompileContext1);
286287 % %% on_enter_html
287288 % html_flow -> on_enter_html(CompileContext1);
@@ -668,6 +669,25 @@ on_enter_hard_break(CompileContext1 = #markdown_mdast_compile_context{}) ->
668669 ),
669670 {ok , CompileContext2 }.
670671
672+ % % @private
673+ -doc """
674+ Handle [`Enter`][Kind::Enter]:[`HeadingAtx`][Name::HeadingAtx].
675+ """ .
676+ -spec on_enter_heading (CompileContext ) -> {ok , CompileContext } when
677+ CompileContext :: markdown_mdast_compile_context :t ().
678+ on_enter_heading (CompileContext1 = # markdown_mdast_compile_context {}) ->
679+ CompileContext2 =
680+ markdown_mdast_compile_context :tail_push (
681+ CompileContext1 ,
682+ markdown_mdast_node :heading (# markdown_mdast_heading {
683+ % Will be set later.
684+ depth = 0 ,
685+ children = markdown_vec :new (),
686+ position = none
687+ })
688+ ),
689+ {ok , CompileContext2 }.
690+
671691% % @private
672692-doc """
673693Handle [`Enter`][Kind::Enter]:[`Image`][Name::Image].
@@ -979,8 +999,9 @@ exit(CompileContext1 = #markdown_mdast_compile_context{events = Events, index =
979999 on_exit_hard_break (CompileContext1 );
9801000 hard_break_trailing ->
9811001 on_exit_hard_break (CompileContext1 );
982- % %% on_exit_heading_atx_sequence
983- % heading_atx_sequence -> on_exit_heading_atx_sequence(CompileContext1);
1002+ % % on_exit_heading_atx_sequence
1003+ heading_atx_sequence ->
1004+ on_exit_heading_atx_sequence (CompileContext1 );
9841005 % %% on_exit_heading_setext
9851006 % heading_setext -> on_exit_heading_setext(CompileContext1);
9861007 % %% on_exit_heading_setext_underline_sequence
@@ -1465,6 +1486,39 @@ on_exit_hard_break(CompileContext1 = #markdown_mdast_compile_context{}) ->
14651486 {ok , CompileContext3 }
14661487 end .
14671488
1489+ % % @private
1490+ -doc """
1491+ Handle [`Exit`][Kind::Exit]:[`HeadingAtxSequence`][Name::HeadingAtxSequence].
1492+ """ .
1493+ -spec on_exit_heading_atx_sequence (CompileContext ) -> {ok , CompileContext } when
1494+ CompileContext :: markdown_mdast_compile_context :t ().
1495+ on_exit_heading_atx_sequence (
1496+ CompileContext1 = # markdown_mdast_compile_context {bytes = Bytes , events = Events , index = Index }
1497+ ) ->
1498+ Slice = markdown_slice :from_position (Bytes , markdown_position :from_exit_event (Events , Index )),
1499+ SliceBytes = markdown_slice :as_binary (Slice ),
1500+ NodeMutFunc = fun on_exit_heading_atx_sequence__node_mut_func /2 ,
1501+ Depth = byte_size (SliceBytes ),
1502+ {CompileContext2 , none } = markdown_mdast_compile_context :tail_mut (CompileContext1 , {some , Depth }, NodeMutFunc ),
1503+ {ok , CompileContext2 }.
1504+
1505+ % % @private
1506+ -spec on_exit_heading_atx_sequence__node_mut_func (Node , OptionDepth ) -> {Node , OptionDepth } when
1507+ Node :: markdown_mdast_node :t (), OptionDepth :: markdown_option :t (Depth ), Depth :: pos_integer ().
1508+ on_exit_heading_atx_sequence__node_mut_func (
1509+ Node1 = # markdown_mdast_node {inner = Heading1 = # markdown_mdast_heading {depth = 0 }}, {some , Depth }
1510+ ) ->
1511+ Heading2 = Heading1 # markdown_mdast_heading {depth = Depth },
1512+ Node2 = Node1 # markdown_mdast_node {inner = Heading2 },
1513+ {Node2 , none };
1514+ on_exit_heading_atx_sequence__node_mut_func (
1515+ Node1 = # markdown_mdast_node {inner = # markdown_mdast_heading {}}, {some , _Depth }
1516+ ) ->
1517+ % % Depth already set, don't override
1518+ {Node1 , none };
1519+ on_exit_heading_atx_sequence__node_mut_func (_Node = # markdown_mdast_node {}, {some , _Depth }) ->
1520+ ?'unreachable!' (" expected heading on stack" , []).
1521+
14681522% % @private
14691523-doc """
14701524Handle [`Exit`][Kind::Exit]:[`LabelText`][Name::LabelText].
0 commit comments