@@ -233,10 +233,10 @@ enum ImGuiMarkdownFormatFlags_
233233{
234234 ImGuiMarkdownFormatFlags_None = 0 ,
235235 ImGuiMarkdownFormatFlags_DiscardExtraNewLines = 1 << 0 , // (Accurate parsing) Provided markdown will discard all redundant newlines
236- ImGuiMarkdownFormatFlags_NoNewLineIfHeadingFirstLine = 1 << 1 , // (Accurate parsing) Provided markdown will not format a newline after the first line if it is a heading
236+ ImGuiMarkdownFormatFlags_NoNewLineBeforeHeading = 1 << 1 , // (Accurate parsing) Provided markdown will not format a newline after the first line if it is a heading
237237 ImGuiMarkdownFormatFlags_SeperatorDoesNotAdvance = 1 << 2 , // (Accurate parsing) Provided markdown will not advance to the next line after formatting a seperator
238- ImGuiMarkdownFormatFlags_GithubStyle = ImGuiMarkdownFormatFlags_DiscardExtraNewLines | ImGuiMarkdownFormatFlags_NoNewLineIfHeadingFirstLine | ImGuiMarkdownFormatFlags_SeperatorDoesNotAdvance,
239- ImGuiMarkdownFormatFlags_CommonMarkAll = ImGuiMarkdownFormatFlags_DiscardExtraNewLines | ImGuiMarkdownFormatFlags_NoNewLineIfHeadingFirstLine | ImGuiMarkdownFormatFlags_SeperatorDoesNotAdvance,
238+ ImGuiMarkdownFormatFlags_GithubStyle = ImGuiMarkdownFormatFlags_DiscardExtraNewLines | ImGuiMarkdownFormatFlags_NoNewLineBeforeHeading | ImGuiMarkdownFormatFlags_SeperatorDoesNotAdvance,
239+ ImGuiMarkdownFormatFlags_CommonMarkAll = ImGuiMarkdownFormatFlags_DiscardExtraNewLines | ImGuiMarkdownFormatFlags_NoNewLineBeforeHeading | ImGuiMarkdownFormatFlags_SeperatorDoesNotAdvance,
240240};
241241
242242namespace ImGui
@@ -294,7 +294,6 @@ namespace ImGui
294294 const MarkdownConfig* config = NULL ;
295295 const char * text = NULL ;
296296 int32_t textLength = 0 ;
297- bool firstLine = false ; // true if this line of text is the first (used for headings)
298297 };
299298
300299 typedef void MarkdownLinkCallback ( MarkdownLinkCallbackData data );
@@ -357,7 +356,7 @@ namespace ImGui
357356 struct TextRegion ;
358357 struct Line ;
359358 inline void UnderLine ( ImColor col_ );
360- inline void RenderLine ( const char * markdown_, Line& line_, TextRegion& textRegion_, const MarkdownConfig& mdConfig_, bool firstLine );
359+ inline void RenderLine ( const char * markdown_, Line& line_, TextRegion& textRegion_, const MarkdownConfig& mdConfig_ );
361360
362361 struct TextRegion
363362 {
@@ -454,7 +453,7 @@ namespace ImGui
454453 ImGui::GetWindowDrawList ()->AddLine ( min, max, col_, 1 .0f );
455454 }
456455
457- inline void RenderLine ( const char * markdown_, Line& line_, TextRegion& textRegion_, const MarkdownConfig& mdConfig_, bool firstLine )
456+ inline void RenderLine ( const char * markdown_, Line& line_, TextRegion& textRegion_, const MarkdownConfig& mdConfig_ )
458457 {
459458 // indent
460459 int indentStart = 0 ;
@@ -470,7 +469,6 @@ namespace ImGui
470469 // render
471470 MarkdownFormatInfo formatInfo;
472471 formatInfo.config = &mdConfig_;
473- formatInfo.firstLine = firstLine;
474472 int textStart = line_.lastRenderPosition + 1 ;
475473 int textSize = line_.lineEnd - textStart;
476474 if ( line_.isUnorderedListStart ) // render unordered list
@@ -535,8 +533,6 @@ namespace ImGui
535533 int concurrentEmptyNewlines = 0 ;
536534 bool appliedExtraNewline = false ;
537535
538- bool firstLine = true ;
539-
540536 char c = 0 ;
541537 for ( int i=0 ; i < (int )markdownLength_; ++i )
542538 {
@@ -673,7 +669,7 @@ namespace ImGui
673669 em = Emphasis ();
674670 // render previous line content
675671 line.lineEnd = link.text .start - ( link.isImage ? 2 : 1 );
676- RenderLine ( markdown_, line, textRegion, mdConfig_, firstLine );
672+ RenderLine ( markdown_, line, textRegion, mdConfig_ );
677673 line.leadSpaceCount = 0 ;
678674 link.url .stop = i;
679675 line.isUnorderedListStart = false ; // the following text shouldn't have bullets
@@ -792,7 +788,7 @@ namespace ImGui
792788 if ( lineEnd > line.lineStart )
793789 {
794790 line.lineEnd = lineEnd;
795- RenderLine ( markdown_, line, textRegion, mdConfig_, firstLine );
791+ RenderLine ( markdown_, line, textRegion, mdConfig_ );
796792 ImGui::SameLine ( 0 .0f , 0 .0f );
797793 line.isUnorderedListStart = false ;
798794 line.leadSpaceCount = 0 ;
@@ -801,7 +797,7 @@ namespace ImGui
801797 line.lastRenderPosition = em.text .start - 1 ;
802798 line.lineStart = em.text .start ;
803799 line.lineEnd = em.text .stop ;
804- RenderLine ( markdown_, line, textRegion, mdConfig_, firstLine );
800+ RenderLine ( markdown_, line, textRegion, mdConfig_ );
805801 ImGui::SameLine ( 0 .0f , 0 .0f );
806802 line.isEmphasis = false ;
807803 line.lastRenderPosition = i;
@@ -819,7 +815,7 @@ namespace ImGui
819815 line.lineEnd = line.lineStart ;
820816 line.lineStart = start;
821817 line.lastRenderPosition = start - 1 ;
822- RenderLine ( markdown_, line, textRegion, mdConfig_, firstLine );
818+ RenderLine ( markdown_, line, textRegion, mdConfig_ );
823819 line.lineStart = line.lineEnd ;
824820 line.lastRenderPosition = line.lineStart - 1 ;
825821 }
@@ -840,7 +836,7 @@ namespace ImGui
840836 else
841837 {
842838 // render the line: multiline emphasis requires a complex implementation so not supporting
843- RenderLine ( markdown_, line, textRegion, mdConfig_, firstLine );
839+ RenderLine ( markdown_, line, textRegion, mdConfig_ );
844840 }
845841
846842 // reset the line and emphasis state
@@ -877,7 +873,7 @@ namespace ImGui
877873 {
878874 --line.lineEnd ;
879875 }
880- RenderLine ( markdown_, line, textRegion, mdConfig_, firstLine );
876+ RenderLine ( markdown_, line, textRegion, mdConfig_ );
881877 }
882878 }
883879
@@ -1127,7 +1123,7 @@ namespace ImGui
11271123 }
11281124 if (start_)
11291125 {
1130- if ( 0 == ( markdownFormatInfo_.config ->formatFlags & ImGuiMarkdownFormatFlags_NoNewLineIfHeadingFirstLine ) )
1126+ if ( 0 == ( markdownFormatInfo_.config ->formatFlags & ImGuiMarkdownFormatFlags_NoNewLineBeforeHeading ) )
11311127 {
11321128 ImGui::NewLine ();
11331129 }
0 commit comments