Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion org.eclipse.lsp4e/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.12.0",
org.eclipse.e4.core.commands,
org.eclipse.compare.core,
org.eclipse.compare,
org.commonmark;bundle-version="0.23.0"
org.commonmark;bundle-version="0.23.0",
org.commonmark.ext-gfm-tables;bundle-version="0.23.0"
Bundle-ClassPath: .
Bundle-Localization: plugin
Bundle-ActivationPolicy: lazy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import java.util.function.Predicate;
import java.util.stream.Collectors;

import org.commonmark.Extension;
import org.commonmark.ext.gfm.tables.TablesExtension;
import org.commonmark.node.Node;
import org.commonmark.parser.Parser;
import org.commonmark.renderer.html.HtmlRenderer;
Expand Down Expand Up @@ -111,9 +113,10 @@ public class LSPTextHover implements ITextHover, ITextHoverExtension, ITextHover
.collect(Collectors.joining("\n\n")) //$NON-NLS-1$
.trim();
if (!result.isEmpty()) {
Parser parser = Parser.builder().build();
List<Extension> extensions = List.of(TablesExtension.create());
Parser parser = Parser.builder().extensions(extensions).build();
Node document = parser.parse(result);
HtmlRenderer renderer = HtmlRenderer.builder().build();
HtmlRenderer renderer = HtmlRenderer.builder().extensions(extensions).build();
Comment on lines -114 to +119
Copy link
Copy Markdown
Contributor

@FlorianKroiss FlorianKroiss Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JavaDoc of Parser indicates that the instances is thread-safe. commonmark/commonmark-java#83 seems to indicate that HtmlRendere is also thread-safe
Can we create singleton instances of the classes instead and re-use them?

I think it would also makes sense to make this rendering code into a utility method so we can write a small unit test, which makes sure that Table-Rendering still works.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comment. Yes, that makes sense, I will do that if I have some extra time.

return renderer.render(document);
} else {
return null;
Expand Down
Loading