markdown document preview improvements#9240
Conversation
|
only took a quick look at the output of some readme files and I think it looks better. Will need some tweaks for the dark theme since the background renders as white atm etc. |
af46460 to
1982844
Compare
|
We already talked about "customization" and it is fine to make it hard coded, but can't we do it direclty inside a css file. it is still hard coded but I can change this, if i want in the settings. So my idea is to add the css to the css file and read it from there. |
I remember being a hustle to include a css resource file and after in runtime in the compiled state to read it. And this is my worry about this, in my personal opinion it doesn't seem to be efficient. |
|
Ok, no worries, I forgot that problem. So everything seems fine :) |
|
: )) thanks. |
|
Bundle could be also fine, yes. |
|
Bundle would be OK for allowing platform applications to override. Not sure if any are using this. But the config file system is probably a better choice if we want to allow IDE users to override? Also, in reference to what @mbien mentioned above, probably a light and a dark CSS file should be available, with the correct one loaded on the basis of checking for the dark theme flag? |
|
I think there is enough time to see where this goes :) . The problem with custom css upload is that Java Swing doesn't really render well css styling, so it's not really useful for users. Maybe combining Fonts & Colors and styling content with placeholders could work to give some level of customization. |
taking the editor background might be good enough or not setting it at all (-> transparent?) which would inherit it automatically from the theme / customized flatlaf properties. |
|
Better to use an Although given how use of this pattern is growing, we could probably do with providing an API for it, probably in the adjacent |
|
checking for dark theme would imply that it would switch between two sets of hardcoded colors or css. Which I believe would be good to avoid and simply inherit the color from somewhere else. I am somewhat skeptical that exposing the css to the user is needed and/or useful, given that it would clash with theming if not done carefully. This started as attempt to improve the defaults which is great (defaults are important!), but the customizable css is kept being added as feature creep distracting from the original goal. Looking through this changeset it appears that there are only a few colors needed atm - with a bit of luck they all can be derived from already existing colors in the IDE. |
|
Customization is secondary to the fact that this belongs on the system filesystem, like other similar configuration. |
8fc9b91 to
120d595
Compare
120d595 to
da16438
Compare
matthiasblaesing
left a comment
There was a problem hiding this comment.
In general I think this is a good improvement. I left a few inline comments though.
ide/markdown/src/org/netbeans/modules/markdown/MarkdownDataObject.java
Outdated
Show resolved
Hide resolved
ide/markdown/src/org/netbeans/modules/markdown/MarkdownViewerElement.java
Show resolved
Hide resolved
ide/markdown/src/org/netbeans/modules/markdown/resources/layer.xml
Outdated
Show resolved
Hide resolved
ide/markdown/src/org/netbeans/modules/markdown/MarkdownViewerElement.java
Outdated
Show resolved
Hide resolved
ide/markdown/src/org/netbeans/modules/markdown/utils/Bundle.properties
Outdated
Show resolved
Hide resolved
bd27cea to
93a4bc5
Compare
mbien
left a comment
There was a problem hiding this comment.
noticed this warning while testing (used the dev build with fresh config):
WARNING [org.netbeans.modules.editor.settings.storage.ProfilesTracker]: Ignoring profile 'Earth' (Editors/text/x-markdown-nb-preview/FontsColors/Earth) in favor of 'NetBeansEarth' (Editors/FontsColors/NetBeansEarth) with the same display name.
interestingly this warning shows only up mentioning the Earth profile. (I used the default FlatLafLight and Dark themes)
ide/markdown/src/org/netbeans/modules/markdown/MarkdownViewerElement.java
Outdated
Show resolved
Hide resolved
| appendColoringCssRulesFromFontConfigs(ss); | ||
| } | ||
|
|
||
| public static void addRule(StyleSheet ss, AttributeSet attributeSet, AttributeSet defaultAttributes) { |
There was a problem hiding this comment.
I found a problem while experimenting with this. I tried to set the headings all to a "fancy" font, so that I can recognize the change. See this preview:
The preview shows, that H1 is changed, but H2 remains the base font. That is in contrast to the configuration:
The configuration (FontAndColors.xml) indicates that H2 should inherit from H1 and in the settings this is correctly recognized (see final "Font" setting for H2).
I think the problem is that the attribute application here does not follow the inheritance tree.
There was a problem hiding this comment.
Yes, the inheritance is not really working and another thing might be that the anchor link element doesn't have any styling options.
The thing is that I've never thought about styling a markdown preview. I don't know what are the end-user behavior and needs.
So, I would try to limit to these 2 feature analysis to free up time.
I think it's at a workable level so far :) .
There was a problem hiding this comment.
Other possible todos:
- use 14px for the inline code size (it seems there is some render issue)
- decrease contrast on code background color for dark modes.
- line height or padding for code text
There was a problem hiding this comment.
Ok - lets keep this minimal. Please have a look here:
There are two different things in here:
- Remove the inheritance marker. I had a prototype for inheritance, but that is even more complex and brings more questions than answers. For real inheritance you'd need to gather all
AttributeSetsthat are chained using thedefaultattribute and create a composite set (there is a helper in the editor settings for that). - Simplify the
StyleUtils. With the current implementationaddRulewill be invoked for each attribute name, in effect adding the AttributeSet multiple times. I removed the iteration over the attributes as there is alreay a guard insideaddRule.
|
I thought I could "humble" Swing's Html editor but I think in the future we might need to replace html and css content rendering with something like For the moment at least it looks a bit more modern and there is the option to customize using Netbeans font config themes. |
matthiasblaesing
left a comment
There was a problem hiding this comment.
Thank you very much. Seems to work nicely. Here is a before (left) and after (after) shot:
To me this looks sane.
@lkishalmi as you are active in this area, could you please also have a look?
|
also: don't forget to squash before merging ;). There is also a optional checklist in the PR template in case its useful - if not, feel free to remove it on future PRs. (its mostly intended as a guide for less active committers) |
|
All right :) . I think I began to get used to the PR flow, so I think I could remove it in the future. |
Closes apache#6652 - bump java release version to 17 - custom <hr> tag renderer - added flexmark strikethrough extension - update vscode regex for striketrhough detection - updated mime type to the latest official text/markdown - created new mime type for preview - using a default skeleton css code for margin, paddings ... - added font configs for markdown preview - link coloring and font size customization css to font config settings
f52af58 to
3f4b0ef
Compare
|
Hey @haidubogdan , just wanted to say thanks for your efforts on this! |

This PR proposes some hard coded styling improvements for markdown preview renderer.
Swing html renderer has a lot of Css limitations, so future improvements could look at using other html java renderers
Before:
After:
Closes #6652
<hr>tag rendererKnow limitations
<code>don't apply padding^Add meaningful description above
Click to collapse/expand PR instructions
By opening a pull request you confirm that, unless explicitly stated otherwise, the changes -
Please make sure (eg.
git log) that all commits have a valid name and email address for you in the Author field.If you're a first time contributor, see the Contributing guidelines for more information.
If you're a committer, please label the PR before pressing "Create pull request" so that the right test jobs can run.
PR approval and merge checklist:
If this PR targets the delivery branch: don't merge. (full wiki article)