Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tables in Markdown editor #78

Closed
elnull opened this issue Feb 17, 2016 · 29 comments
Closed

Tables in Markdown editor #78

elnull opened this issue Feb 17, 2016 · 29 comments
Labels
Type: Feature adds functionality
Milestone

Comments

@elnull
Copy link
Contributor

elnull commented Feb 17, 2016

Is it possible to add tables detection to editor's parser and output them with monospace font?

@pbek
Copy link
Owner

pbek commented Feb 17, 2016

Which table syntax are we talking of?

@elnull
Copy link
Contributor Author

elnull commented Feb 17, 2016

@pbek
Copy link
Owner

pbek commented Feb 17, 2016

Hm, maybe if a line starts and ends with an | we could make it a code block. What do you think, would that be enough?

@pbek pbek added Type: Feature adds functionality Help wanted labels Feb 17, 2016
@elnull
Copy link
Contributor Author

elnull commented Feb 17, 2016

It would be enough if your parser doesn't support multiline. I think the better test for tables would be search for sequential lines with same count of |.

@pbek
Copy link
Owner

pbek commented Feb 17, 2016

The parser is generated from a lexer of PEG Markdown Highlight.
The Lexer looks like this:
https://github.com/pbek/qmarkdowntextedit/blob/develop/lib/peg-markdown-highlight/pmh_grammar.leg

If you can come up with a lexer statement that works, I will integrate it 😸

@DivineDominion
Copy link

DivineDominion commented Jun 20, 2016

When you use PEG Markdown: there's PEG MultiMarkdown which includes table syntax already.

@pbek
Copy link
Owner

pbek commented Jun 20, 2016

@DivineDominion is there a Qt implementation for it?

@Maboroshy
Copy link
Contributor

Maboroshy commented Oct 21, 2016

I was converting some old tables to markdown and it has not been easy. I had to add code tags to edit table in monospace. Then delete code tags for rendering. And all that many times.

I think that highlighter should put to monospace anything between |. Like |I'm a table|. Yes that doesn't cover no outside borders style (it makes it unusable really) but at least half is covered.

Another issue is that rendered tables have no grid lines. I find it hard to read wide tables without a grid. That looks like a css thing, haven't worked out that yet.

@pbek
Copy link
Owner

pbek commented Oct 21, 2016

It will be easier when QOwnNotes would use a fully fledged browser component for previewing (which doesn't work right now because it would break Debian 8.0 support). But the disadvantage would be the increased ram consumption...

@Maboroshy
Copy link
Contributor

I'm not really looking forward to having fully fledged browser in the app. It's not the RAM that makes me unsure that it's the good path but the responsiveness of the app. All "browser inside" apps I saw lacked it. Like that Typora thing some user mentioned - browser and fancy JS stuff allows many smart UI features, but it's loading too slow for a minimalistic editor and scrolling is lagging for half a second with a big document. No feature will make me use plain text editor that has scrolling lagging.

@pbek
Copy link
Owner

pbek commented Nov 27, 2016

16.11.15

  • a new markdown parser and highlighter was now implemented from
    scratch to allow a higher parsing speed and more flexibility in the future
    • text will now be instantly highlighted, there is no
      highlighting-interval setting any more
    • now you also can change the styling in the settings or
      enable/disable the highlighting without re-starting the application
    • please report issues with the new highlighter if you find any
  • markdown tables are now supported by the new markdown highlighter
    • the mono-space code font is used for it
    • you can change the highlighting color and other styles in the settings

feedback is welcome, @elnull, @DivineDominion, @Maboroshy, @jd666

@pbek pbek added this to the 16.11.15 milestone Nov 27, 2016
@pbek pbek removed the Help wanted label Nov 27, 2016
@Maboroshy
Copy link
Contributor

Maboroshy commented Nov 27, 2016

First impressions:

  1. All good and fast.
  2. Table highlighting works correctly, also with "no outside border style". I had one misfire on some link having a title with sevral |. I understand that | is rare in normal text, but having kind of priority for link highlighting over table highlighting would be good.
  3. Highlighter doesn't parse ![](file://) as an image, it wants at least a space in the title. Yet it's a valid renderable markdown, and I have plenty of those. I wanted to make a pull request, but looks like markdown syntax definitions are gone out of the app to upstream now.

@Maboroshy
Copy link
Contributor

Also # I'm a header [link](url) highlighted as a simple header now. Previously it was highlighted correctly with a specific highlighting for a link inside.

@Maboroshy
Copy link
Contributor

Links without syntax like http://url are not highlighted. I'm not sure but I remember they were highlighted before and even had an entry in colour scheme editor. I may be wrong though.

@pbek
Copy link
Owner

pbek commented Nov 27, 2016

Thank you for your feedback, @Maboroshy! I'll see what I can do.

@pbek
Copy link
Owner

pbek commented Nov 28, 2016

@Maboroshy

but looks like markdown syntax definitions are gone out of the app to upstream now

Actually it even went two steps down-steam :)
The highlighting was always done in https://github.com/pbek/qmarkdowntextedit.
But before the parsing in qmarkdowntextedit used a 3rd party library that used a 4th party library.

I fixed now all of it and more in 16.11.16.

@pbek
Copy link
Owner

pbek commented Nov 28, 2016

16.11.16

  • markdown syntax highlighting improvements
    • better multi-line html comment detection
    • image links like ![](file://) work now
    • it's now possible to have links and italic/bold formatting in a headline
    • urls without any other markup are now highlighted too
      • they can now also be opened with Ctrl + Click
    • formatting bold and italic with __bold__ and _italic_ now also works
    • fixed a wrongly detected table in a link
  • you can now insert a markdown table with the new shortcut Alt + + T
    • a markdown table wizard will be opened to create an empty table to work with

@pbek
Copy link
Owner

pbek commented Nov 28, 2016

There now is a new release, could you please test it and report if the new features work for you?

@pbek
Copy link
Owner

pbek commented Nov 28, 2016

@Maboroshy, sourceforge has problems, you might need to wait for your AUR release... :/

@Maboroshy
Copy link
Contributor

Maboroshy commented Nov 28, 2016

The highlighting was always done in https://github.com/pbek/qmarkdowntextedit.

My bad. For some reason I thought that qmarkdowntextedit was some Qt thing.

After the last fix finding new bugs is a challenge. I accept it though. 😎

@pbek
Copy link
Owner

pbek commented Nov 28, 2016

My bad. For some reason I thought that qmarkdowntextedit was some Qt thing.

nah, I created it for QOwnNotes and made it a library for others to use...

After the last fix finding new bugs is a challenge. I accept it though. 😎

You always do. ;)

@Maboroshy
Copy link
Contributor

Maboroshy commented Nov 29, 2016

Ok then, here we go.

  1. Images highlighted in a weird way. I see ! or ![] part highlighted as image and [title](url) part highlighted as a link. Two colour code is fancy though.
  2. Bolds and italics are highlighted inside table monospace making monospace not that "mono". And I don't remember it in previous version.
[
ti
tle](
url
)

is not highlighted as a link, same for image. Yet it's valid and does render.

I'm still to learn QRegularExpression but some ?s in regexps, like in !\\[.*?\\]\\(.+?\\), make me... uneasy.

@pbek
Copy link
Owner

pbek commented Nov 29, 2016

Thank you for testing, I will take a look at 1) and 2). I will not take care of 3), that would be much too bothersome with QSyntaxHighlighter.
The ? in this case is for non-greedy matching.

@pbek
Copy link
Owner

pbek commented Nov 30, 2016

16.11.18

  • fixed a highlighting issue with images and tables

@pbek
Copy link
Owner

pbek commented Nov 30, 2016

16.11.18

  • fixed highlighting issues with images and tables
  • dramatically reduced the loading time of large notes
    • the navigation tree in the navigation panel was rebuilt too often
      with the new highlighter

There now is a new release, could you please test it and report if the new features work for you?

@Maboroshy
Copy link
Contributor

Maboroshy commented Nov 30, 2016

Looks like everything working now, except 3 of course. I tuned Bash-note to correct multiline links from converted web pages anyway. Some legacy stuff left.

@pbek
Copy link
Owner

pbek commented Nov 30, 2016

Great, thank you!

@pbek pbek closed this as completed Nov 30, 2016
@pbek
Copy link
Owner

pbek commented Dec 3, 2016

16.12.0

  • you can now import csv files with the Insert table dialog
    • you'll get a preview of the content of your csv file
    • you can choose your separator, text-delimiter and whether the
      first line is the table heading
  • more highlighting fixes
    • fixed an issue with other highlighting inside an inline code block
    • table highlighting support for tables, that don't start with a |
      was dropped, that's far to messy to deal with

@pbek
Copy link
Owner

pbek commented Dec 3, 2016

There now is a new release, could you please test it and report if the new features work for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature adds functionality
Projects
None yet
Development

No branches or pull requests

4 participants