Git Product home page Git Product logo

markdown-javafx-renderer's Introduction

MDFX has moved to JPro Platform!

๐Ÿšจ IMPORTANT NOTICE: This repository has been relocated. All the content, issues, and activity have been transferred to our new repository.

Why did we move?

We've decided to consolidate our repositories into a single one to better manage and streamline our projects. This will allow us to better prioritize and address issues and pull requests, as well as to release new versions faster.


JPro supported JFX-Central Build Status

MDFX is a simple markdown-renderer for JavaFX. It's based on flexmark-java. It is used to render the documentation for jpro at jpro.one.

Usage

Add the library to your project:

For Gradle, add the following to your build.gradle:

Add the following repository:

repositories {
    maven {
        url "https://sandec.jfrog.io/artifactory/repo"
    }
}

Add The following dependency:

dependencies {
    compile "com.sandec:mdfx:0.2.12"
}

Usage:

import com.sandec.mdfx.MarkdownView;

MarkdownView mdfx = new MarkdownView("your-markdown");

Simple Application: Source Code

Feature Overview: Reference-Markdown-File

You can personalize the looking of your markdown via css. Minimal default-file To use your own css, you have to overwrite the getDefaultStylehsheets.

protected List<String> getDefaultStylehsheets() {
    return List.of("/your-css.css");
}

Alternatively, you can also return an empty list, and add your css via the getStylesheets of the Scene.

Changelog

0.2.12 (28. March 2023)

  • It's no longer necessary to add the default-css. You can add your own css via getDefaultStylehsheets.

0.2.11

  • Fixed wrong layouting of the Image.

0.2.10

  • Added a new default implementation for Images. The images no longer expand outside of the viewport.
  • The images are now also loaded asynchronously.

0.2.9

  • Fixed an issue, which caused that sometimes a whitespace was missing in links.

0.2.8 (13. October 2022)

  • Changed JavaFX Dependencie to be compile only.

0.2.7 (10. March 2022)

  • Updated Flexmark to 0.64

0.2.6 (10. March 2022)

  • Fixed Newline character in links.

0.2.5 (11. November 2021)

  • Fixed an bug with nested Sorted/Unsorted lists.

0.2.4

  • Fixed an layouting issue with lists. In some situations "..." was shown for left label counting the entries.

0.2.3

  • The blockquote is now configured with the css variables -mdfx-bq-color-border and -mdfx-bq-color-border. Users might want to add these variables to their css.
  • Ordered lists start now with 1 instead of 0.

0.2.2

  • -- skip this version --

0.2.1

  • Added support for BlockQuotes
  • Added support for TaskLists
  • Renamed MDFXNode to MarkdownView
  • Moved internal classes to an impl package

0.2.0

  • Added support for ordered lists.
  • We now us the Java11 Module System. At least Java11 is now required.

0.1.9

  • Added support for strikethrough
  • It's now possible to change the link color in the css with -mdfx-link-color
  • Updated flexmark to 0.62.2

0.1.8

  • The property mdString of MDFXNode is now public

Development

Run the sample:

./gradlew example:run
./gradlew example:jproRun

Deploy new release:

./gradlew :publish

markdown-javafx-renderer's People

Contributors

besidev avatar floriankirmaier avatar hhsandbaek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

markdown-javafx-renderer's Issues

Make `mdStringProperty` public

Hi all!

Firstly I want to thank you for creating this awesome library, it's really useful.

I created a markdown editor control for JavaFX (which is available in this repo) that uses the MDFXNode for rendering the markdown.

Gif demo

As you can see, it synchronizes the renderer with the text area continuously.

The problem is that the MDFXNode class does not provide a public member that allows to change the content of an already existing MDFXNode object. So I looked into the source code, and I found a package-private StringProperty reference with the name mdStringProperty. Unfortunately, I have to use reflection to access it due to it's restricted visibility.

        try {
            Field field = MDFXNode.class.getDeclaredField("mdStringProperty");
            field.setAccessible(true);
            return (StringProperty) field.get(this);
        } catch (ReflectiveOperationException e) {
            throw new RuntimeException(e);
        }

You can view the full code here.

Would you create a public getter method for that reference?

Thanks for everything.
Best regards

java.lang.ClassNotFoundException: com.sun.prism.es2.X11GLFactory + Fix

Hi,

thanks for this great library.
When I first added it to my project, it threw this exception:

GLFactory.static - Platform: Linux - not available: com.sun.prism.es2.X11GLFactory
java.lang.ClassNotFoundException: com.sun.prism.es2.X11GLFactory
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:315)
	at javafx.graphics/com.sun.prism.es2.GLFactory$FactoryLoader.run(GLFactory.java:110)
	at javafx.graphics/com.sun.prism.es2.GLFactory$FactoryLoader.run(GLFactory.java:100)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at javafx.graphics/com.sun.prism.es2.GLFactory.<clinit>(GLFactory.java:97)
	at javafx.graphics/com.sun.prism.es2.ES2Pipeline.<clinit>(ES2Pipeline.java:77)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:315)
	at javafx.graphics/com.sun.prism.GraphicsPipeline.createPipeline(GraphicsPipeline.java:218)
	at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:91)
	at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:124)
	at java.base/java.lang.Thread.run(Thread.java:834)
java.lang.ClassNotFoundException: com.sun.glass.ui.gtk.GtkPlatformFactory
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:315)
	at javafx.graphics/com.sun.glass.ui.PlatformFactory.getPlatformFactory(PlatformFactory.java:42)
	at javafx.graphics/com.sun.glass.ui.Application.run(Application.java:144)
	at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:280)
	at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:288)
	at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:160)
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:658)
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:409)
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Failed to load Glass factory class
Exception in thread "main" java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.NullPointerException
	at javafx.graphics/com.sun.glass.ui.Application.run(Application.java:144)
	at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:280)
	at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:288)
	at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:160)
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:658)
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:409)
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
	... 5 more

Caused by: java.lang.NullPointerException

Because I have struggled with dependencies which have JavaFX as their own dependency before, I was able to fix this error by declaring the dependency like this:

implementation("com.sandec:mdfx:0.1.8") {
   exclude group: "org.openjfx"
}

I suggest you add it to your readme in some form. Also, in the readme, your repo uses http instead of https. Also also, the link to the example is broken in the readme.

CSS properties for blockquote colors

Hi!

Thanks for the awesome enhancements you added to this library.

It would be great to have CSS properties for defining the blockquote's colors.
Like this:

* {
   ...
    /* Blockquotes */
   -mdfx-bc-color-1: cyan; /* the blockquote's border color */
   -mdfx-bc-color-2: lightgray; /* the blockquote's background color */
}

Best regards
Daniel

Strikethrough doesn't work

Hi!

I noticed that strikethrough doesn't work in the renderer.
Is it a bug or simply the MDFXNode doesn't support it?

image

Greetings Daniel

Links in README.md do not work

It seems some of the links on the README.md are outdated:

  • Simple Application: Source Code

Feature Overview: Reference-Markdown-File

Unspecified copyright

I'm making a derivative work of this work and as such should provide the copyright in the derivative work, however in the LICENCE file, it is blank: Copyright [yyyy] [name of copyright owner] - the [] need to be replaced

JFXCentral Badge

Would be great if you could add this badge to your readme:

[![JFXCentral](https://img.shields.io/badge/Find_me_on-JFXCentral-blue?logo=googlechrome&logoColor=white)](https://www.jfx-central.com/libraries/mdfx)

Fix invalid code snippet in README

In the code snippet at the Usage section, the new MarkdownView constructor is used but the variable data type is still MDFXNode:

import com.sandec.mdfx.MarkdownView;

MDFXNode mdfx = new MarkdownView("your-markdown"); // Invalid data type
content.getStylesheets().add("/com/sandec/mdfx/mdfx-default.css");

It should be possible to change the base font size.

Right now, the base font size for markdown-text is hard-coded at 16, and is not overwritable by CSS. This is problematic when trying to fit a markdown section into an existing UI. There should be an -mdfx-font-size property like there is -mdfx-font-color.

unknown license

Hi, this is a very nice project that I would like to use. Could you please provide some license information, I could not find any. Thank you very much!

Tasklist support

It seems like MDFXNode doesn't support tasklists.
It's not a big problem because it's not a part of the "base markdown" specification but you can look into this when you have time.

Expected:
image

Actual:
image

Unordered lists alignment

The elements are aligned TOP_LEFT, but should probably be CENTER_LEFT. The hboxes will never be bigger than the content so this should not cause vertical center-aligning of the content. Hovewer, if the bullet is higher than the text, the TOP_LEFT causes the text and bullet to not be aligned properly.

I tested that CENTER_LEFT fixes the issue. However I did not do anough testing to conclude it does not produce issues in some situations

I reproduced the issue by using custom styling with custom and relative font sizes (ems), on desktop.

CSS property for link color

It would be great to have a CSS property like -mdfx-link-color that allows to set the link color.

Then:

* {
    -mdfx-font-color: white;
    -mdfx-border-color-1: #888;

    -mdfx-bg-color-1: #484848;
    -mdfx-bg-color-2: #3c3c3c;
    -mdfx-bg-color-3: #303030;

    -mdfx-link-color: cyan;
}

Note: I tried to use the class selector .markdown-link but somehow that didn't work for me.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.