I'm not sure if this is the right Stack Exchange page to ask (perhaps Programmers is also suitable, although they oppose software-technical questions).

However, for a program that should act as a client to a internal knowledge database, I'm investigating Rich Text controls/widgets from different frameworks. This Rich Text control should display a subset of HTML. Only h1-h6, b, i, img (embedded or not), lists and simple tables are supported. The text is saved in the data model as markdown code.

Now I need a control that displays this markup with online editing (just like text processors) and can save the contents again as markdown. The client can be written in Python (with PyQt or wxPython) or C# with WinForms. I've tested the Rich Text controls in these frameworks, but they were not suitable. WinForms' RichEditBox outputs strange RTF, the others some horribly formatted HTML. Now I want to extend an existing control in such a way that it holds the contents as markdown in every given second.

Are there any good, open-sourced controls/widgets for the mentioned target platforms that could act as a good start?

有帮助吗?

解决方案

Your requirement seems like a bit of an edge case as markdown was specifically designed to be easily written by humans, for processing into other formats. You're doing the opposite, still...

I'm not aware of any WYSIWYG controls that save to Markdown, so you'll probably have to roll your own. What you can do is subclass an existing control and implement a persistence mechanism that fetches the control contents and generates Markdown. That will be tricky because most rich text or HTML editiors will support more features than Markdown does. You should be able to implement the control's input features to limit them to the supported subset in Markdown. There may be some Python projects that will help with the parsing. Pyth looks minimal, but could be useful.

There are plenty of Markdown to Format X converters, but the only tool I know that goes the other way is (Markdownify) which is in PHP.

其他提示

Have a look at Pandoc, which converts to and from reStructuredText, Markdown, HTML and LaTeX (among other formats). There is an online editor which demonstrates the use of Pandoc here. The source of that webpage seems very simple, so perhaps you can try coding something similar up. Pandoc is, however, written in Haskell. The Python equivalent, Docutils, can only convert from reStructuredText (not Markdown) to HTML and other formats and not the otherway around.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top