let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
ConvertToList = Table.AddColumn(Source, "TextAsList", each Text.Split([Text], "#(lf)")),
GetPostionsOfLevel1 = Table.AddColumn(ConvertToList, "PositionsOfLevel1", each List.Combine({{0},List.Transform( List.PositionOf([TextAsList], "", Occurrence.All), each _ + 1)})),
#"Expanded TextAsList" = Table.ExpandListColumn(GetPostionsOfLevel1, "TextAsList"),
AddMainIndex = Table.AddIndexColumn(#"Expanded TextAsList", "Index", 0, 1),
GetLevel = Table.AddColumn(AddMainIndex, "Levels", each if List.First(List.Intersect({{[Index]},[PositionsOfLevel1]})) = [Index] then "L1" else if [TextAsList] = "" then null else "L2"),
GroupOnLevel = Table.Group(GetLevel, {"Levels"}, {{"All", each _, type table [Text=text, TextAsList=text, PositionsOfLevel1=list, Index=number, Levels=text]}}),
Add_L1_Index = Table.AddColumn(GroupOnLevel, "Add_L1_Indx", each if [Levels] = "L1" then Table.AddIndexColumn([All], "L_Indx", 1,1) else [All]),
Expand_Add_L1_Indx = Table.ExpandTableColumn(Add_L1_Index, "Add_L1_Indx", {"TextAsList", "Index", "Levels", "L_Indx"}, {"TextAsList", "Index", "Levels.1", "L_Indx"}),
RemoveCols = Table.RemoveColumns(Expand_Add_L1_Indx,{"Levels","All"}),
SortOnMainIndex = Table.Sort(RemoveCols,{{"Index", Order.Ascending}}),
FillDown = Table.FillDown(SortOnMainIndex,{"L_Indx"}),
GroupOnL1Index = Table.Group(FillDown, {"L_Indx"}, {{"All", each _, type table [TextAsList=text, Index=number, Levels.1=text, L_Indx=number]}}),
Add_L2_Index = Table.AddColumn(GroupOnL1Index, "Add_L2_Indx", each Table.AddIndexColumn([All],"L2_Indx",0,1)),
Expand_Add_L2_Indx = Table.ExpandTableColumn(Add_L2_Index, "Add_L2_Indx", {"TextAsList", "Index", "Levels.1", "L_Indx", "L2_Indx"}, {"TextAsList", "Index", "Levels.1", "L_Indx.1", "L2_Indx"}),
RemoveCols1 = Table.RemoveColumns(Expand_Add_L2_Indx,{"L_Indx", "All"}),
ConvertIndexesToText = Table.TransformColumnTypes(RemoveCols1,{{"L_Indx.1", type text}, {"L2_Indx", type text}}),
ConcatenateIndexes = Table.AddColumn(ConvertIndexesToText, "Headers", each if [Levels.1] = null then null else if [L2_Indx] = "0" then [L_Indx.1]&". " else [L_Indx.1] &"."& [L2_Indx]&" "),
#"Split_Text_By_""-""" = Table.SplitColumn(ConcatenateIndexes, "TextAsList", Splitter.SplitTextByEachDelimiter({"-"}, QuoteStyle.Csv, false), {"TextAsList.1", "TextAsList.2"}),
TrimText = Table.TransformColumns(#"Split_Text_By_""-""",{{"TextAsList.2", Text.Trim, type text}}),
MergeHeadersWithText = Table.CombineColumns(TrimText,{"Headers", "TextAsList.2"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Paragraph Headers"),
KeepOnlyFullHeaderCol = Table.SelectColumns(MergeHeadersWithText,{"Paragraph Headers"}),
CombineInSingleCell = Text.Combine(Table.Column(KeepOnlyFullHeaderCol,"Paragraph Headers"),"#(lf)")
in
CombineInSingleCell