D14738: Add the markdown entry

Yifei Wu noreply at phabricator.kde.org
Fri Aug 17 01:07:14 BST 2018


kqwyf added a comment.


  In D14738#310269 <https://phabricator.kde.org/D14738#310269>, @sirgienko wrote:
  
  > In D14738#310261 <https://phabricator.kde.org/D14738#310261>, @kqwyf wrote:
  >
  > > Here comes a problem...
  > >
  > > The reason I'd like to make rendered markdown entries uneditable is that, if the user edited a rendered markdown entry, then we could never convert the content (in html) back to markdown.
  > >  To imitate the behaviors of latex entries better, I thought it's a good idea that the cursor can move on the markdown entries while they can't be edited.
  >
  >
  > In this moment, if you haven't libspectre (or latex), you can't exec latex entry (well, you can, but nothing happens) and another actions allowed. If you haven't libspectre and load worksheet with 
  >  latex formulas, we can see rendrered images (okay, in this moment, we can't see, but I working on this problem and this will be fix soon on master), but I could edit unrendered latex entries and convert renderered to unrendered entries by double click.
  
  
  Actually, for now most behaviors of a markdown entry are similar to those of a latex entry. The only difference is that when rendered, you can move the cursor in a latex entry and edit the content (by treating the rendered content as a picture) of a latex entry, but you can't move the cursor nor edit the rendered content (except by double clicking) in a markdown entry.
  The reason that the rendered markdown entry shouldn't be edited directly is that it can't be treated as a whole. If my explanation is poor, here's an example (supposing that the markdown entry is always editable and the user has Discount library) :
  
  1. The user inserted a markdown entry, inputed `## Markdown` and evaluated it. So the content was `<h2>Markdown</h2>` in html.
  2. The user single clicked on it (the entry remains rendered) and deleted some characters, for example, `down`. The content became `<h2>Mark</h2>` in html.
  3. The user double clicked on it. In this moment, the user might expect that the content becomes `## Mark`, but actually we can't do it because we can't convert html to markdown. What we have is just the original code, `## Markdown`.
  
  Due to the reason above, I set `Qt::TextBrowserInteraction` when the markdown entry is rendered.
  
  In D14738#310269 <https://phabricator.kde.org/D14738#310269>, @sirgienko wrote:
  
  > As I know, LaTeX entries always set `Qt::TextEditorInteraction` (see LatexEntry constructor), so isEditable() return true, so I think, this code don't give us problems.
  >  And as I see, Text entries do the same.
  
  
  Due to the reason above, markdown entries have to be different from others...
  
  In D14738#310269 <https://phabricator.kde.org/D14738#310269>, @sirgienko wrote:
  
  > LatexEntry and TextEntry don't override `wantFacuse` function from WorksheetEntry, so I don't think, that we need override the function in MarkdownEntry.
  
  
  For the problem above, one solution is to override this function to make the cursor move on the whole worksheet. (or the cursor will be stopped by a markdown entry)
  
  I just came up with another solution which enable the cursor to move onto the markdown entries (and I tested it). We can catch the `KeyPressEvent` in the `eventFilter()` of `m_textItem` and let the cursor move correctly. But as I think, this solution will make the event processing logic messy and confusing.
  
  What should I do?
  
  In D14738#310269 <https://phabricator.kde.org/D14738#310269>, @sirgienko wrote:
  
  > Sorry, but I think, I don't  understand your correctly. Rendered LatexEntry saves eps file to archive. As I know Discount generate full html output from markdown, so Markdown Entry haven't any eps files, isn't it?
  
  
  Sorry for my poor explanation.
  
  I'm implementing MarkdownEntry with both markdown and latex support. I tested Discount with flag MKD_LATEX using a string like "$$\sum$$" and it doesn't work. I'm not sure what's wrong, but I chose another solution to get consistent behaviors. The solution is simple: firstly convert the markdown code (with latex formulas in `$$`) to html by Discount, and then render the latex code by `TextEntry::evaluate()`, which generates several temporary eps files.

REPOSITORY
  R55 Cantor

REVISION DETAIL
  https://phabricator.kde.org/D14738

To: kqwyf, pino, #cantor, filipesaraiva
Cc: sirgienko, filipesaraiva, pino, asemke, kde-edu, narvaez, apol
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-edu/attachments/20180817/742ccd70/attachment-0001.html>


More information about the kde-edu mailing list