enkisoftware / imgui_markdown

Markdown for Dear ImGui
zlib License
1.03k stars 69 forks source link

Escaping symbols #18

Closed mekhontsev closed 3 years ago

mekhontsev commented 3 years ago

This patch adds support of

  1. Emphasis: * or _
  2. Escape symbol: '\'
  3. Horizontal Rules: *** or ___
juliettef commented 3 years ago

Thanks, will take a look

mekhontsev commented 3 years ago

OK. I've just pushed the second commit with other corner cases.

dougbinks commented 3 years ago

Many thanks for the PR!

I have merged this into branch dev_pr18 and will get @juliettef to do some further testing before merging to master & dev

I've made a few changes from your PR:

  1. Removed #include "imgui.h" - you should do that in your own code before including this
  2. Removed #ifndef IMGUI_MARKDOWN_LESS_NEWLINES - formatting changes should be handled by creating your own formatCallback
  3. Modified the rendering of emphasis so it occurs as soon as the final * character is found, which handles an edge case of no characters or newline after the emphasis.
  4. Formatting consistency fixes
dougbinks commented 3 years ago

As you can see from my commit history on this branch there has been a fair amount of work in fixing edge cases: https://github.com/juliettef/imgui_markdown/commits/dev_pr18

I've also removed the escape \ character - this isn't part of default markdown and it caused issues - a full escape implementation would need to check that the following character is an action token character and ignore that, otherwise treat as a normal \ such as in C:\Windows\

dougbinks commented 3 years ago

Note that the multiline emphasis turned out to be difficult to get to work properly, so I've removed this for now - this also simplifies the code a lot.