juliettef / imgui_markdown Goto Github PK
View Code? Open in Web Editor NEWMarkdown for Dear ImGui
License: zlib License
Markdown for Dear ImGui
License: zlib License
I'm not sure the best way to resolve this issue in the repo, but when compiling with GCC on Ubuntu with options -Wall -Wextra -pedantic -Wno-unknown-pragmas -Werror
:
In file included from /some/folder/work/myproj/myproj/src/main.cpp:20:
/home/runner/work/iragui/iragui/libs/imgui_markdown/imgui_markdown.h: In function ‘void ImGui::Markdown(const char*, size_t, const ImGui::MarkdownConfig&)’:
/home/runner/work/iragui/iragui/libs/imgui_markdown/imgui_markdown.h:726:33: error: this statement may fall through [-Werror=implicit-fallthrough=]
726 | if( em.sym == c )
| ^~
/home/runner/work/myproj/myproj/libs/imgui_markdown/imgui_markdown.h:736:25: note: here
736 | case Emphasis::RIGHT:
| ^~~~
cc1plus: all warnings being treated as errors
This warning can be handled in C++17 with the [[fallthrough]] attribute (in fact the linked example is almost this very case!). However, prior to C++17 unknown attributes were not guaranteed to be ignored, so using this attribute could lead to warnings with other toolchains.
I guess one messy solution might be:
#if __cplusplus >= 201703L
[[fallthrough]]
#endif
EDIT:
Actually this fix
case Emphasis::MIDDLE:
if( em.sym == c )
{
em.state = Emphasis::RIGHT;
em.text.stop = i;
// pass through to case Emphasis::RIGHT
[[fallthrough]];
}
else
{
break;
}
case Emphasis::RIGHT:
Results in MSVC warning:
warning C4468: the [[fallthrough]] attribute must be followed by a case label or a default label
Here You show "This is an icon"
I would like to see the code for that since I would like to use ICON_FA_STAR in the markdown but cannot get it to work
Thank you in advance
i need dx9 and dx11 methods
thank you
Hi, im trying this library for my project but when i call the ImGui::Markdown(...)
it segfaults.
here's a snippet of my code (with few modifications as i dont need image and links in markdown so i've removed the corresponding callbacks)
#include "imgui.h"
#include "imgui_markdown.h"
#include "IconsFontAwesome5.h"
//font.cpp
//the following are static variables declared in font.hpp
ImFont* Font::H1;
ImFont* Font::H2;
ImFont* Font::H3;
ImGui::MarkdownConfig Font::md_config;
const char* Font::connected_path = "assets/fonts/test.ttf";
//font loading
const float md_font_size = 12.0f;
ImGuiIO& io = ImGui::GetIO();
// io.Fonts->Clear(); //not called as i load many fonts prior to loading fonts for markdown
io.Fonts->AddFontFromFileTTF(Font::connected_path, md_font_size);
Font::H2 = io.Fonts->AddFontFromFileTTF(Font::connected_path, md_font_size);
Font::H3 = md_config.headingFormats[1].font;
Font::H1 = io.Fonts->AddFontFromFileTTF(Font::connected_path, md_font_size * 1.1f);
//help.cpp
void md_format_cb(const ImGui::MarkdownFormatInfo& md_info, bool start)
{
ImGui::defaultMarkdownFormatCallback(md_info, start);
}
void Help::markdown(const std::string& str_md)
{
Font::md_config.linkCallback = NULL;
Font::md_config.tooltipCallback = NULL;
Font::md_config.imageCallback = NULL;
Font::md_config.linkIcon = NULL;
Font::md_config.headingFormats[0] = { Font::H1, true };
Font::md_config.headingFormats[1] = { Font::H2, true };
Font::md_config.headingFormats[2] = { Font::H3, false };
Font::md_config.userData = NULL;
Font::md_config.formatCallback = md_format_cb;
ImGui::Markdown(str_md.c_str(), str_md.length(), Font::md_config); //segfaults
}
//call
const std::string str = u8R"(
# H1
## H2
### H3
)";
Help::markdown(str);
Backend: opengl2 and glfw
DearImGui Version: 1.81 WIP
There are two problems with the current code concerning text wrapping:
TextRegion
always uses the normal text font to compute the wrap position but the font of a heading is usually larger than that.RenderLine()
function like the other text elements do?@bkaradzic mentions in issue 4 that he would prefer a separate header for the external interface.
The way we use imgui_markdown.h in our project is we expose an external interface via our own string container, and the config isn't exposed. I'd thought people would likely use it that way, but I can see that for library projects they would like to expose a full external interface.
I think there are several alternatives here:
Thoughts?
Add basic table, so we can make item alignment in one row, like this
1 | 2 | 3 |
---|---|---|
column 1 | column2 long text | 3 |
1 | column2 | long text |
It's better if we can hide/show the title of the table, separator lines. thanx
Hi
As mentioned on twitter I started using imgui_markdown in glChAoS.P
Using imgui_markdown with my help strings I realized that it does not display the last character.
If the string is in form:
std::string markdownText = u8R"(
aaaaaP
)";
the problem does not seem to appear, because the last char is \n
, but if I use:
std::string markdownText = u8R"(aaaaaP)";
or a more simple:
std::string markdownText = "aaaaP";
the P
is not printed.
Thanks
I don't see an option to set a void* userdata pointer for the link callback. This forces use of globals some projects will not accept.
There is bug here:
imgui_markdown/imgui_markdown.h
Line 201 in d1726b1
When widthLeft
is too small to fit whole word endPrevLine
doesn't advance and it causes infinite loop.
My workaround was:
if (text == endPrevLine) {
endPrevLine++;
}
Other minor issues:
This:
imgui_markdown/imgui_markdown.h
Line 155 in d1726b1
Should be (fixes clang error):
HeadingFormat headingFormats[ NUMHEADINGS ] = { { NULL, true }, { NULL, true }, { NULL, true } };
Also I would suggest to create .h file that contains only definitions users should use. I did this inside bgfx:
https://github.com/bkaradzic/bgfx/blob/master/3rdparty/dear-imgui/widgets/markdown.h
Sorry for not creating PR...
Thanks a lot ! imgui_markdown is exactly the library I am looking for.
I have one question that whether it can support math formula input as the markdown extension does? Or any solution/advice for doing this?
Branch: dev_format_callback
We'd like some feedback on our new MarkdownFormatCallback for customizable formatting. The way it works is you override DefaultMarkdownFormatCallback in your code to get features you require such as coloured text. See ExampleMarkdownFormatCallback for an example of how it works.
Introducing this method is the first step towards adding features such as bold or italics, and permits much more customisable formatting.
Thoughts?
In most Markdown implementations a line return isn't added unless there are two empty spaces at the end of a line.
This lets you wrap your markdown file nicely in your editor whilst also allowing your end viewer to wrap it accordingly.
Markdown always has bold and italic formatting - which are very useful for emphasis. While I know official Dear Imgui has stated no interest in text formatting I thought maybe you would find interest in adding them.
imgui_markdown currently requires C++14 due to the use of aggregate initializers along with default member initializers. Adding C++11 constructors would break users' code in a way that would be difficult to workaround, and adding initializer list constructors is somewhat of a pain.
Question: do you need C++11 support and why?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.