Skip to content
Open
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
1 change: 1 addition & 0 deletions ide/editor.settings.storage/nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@
<friend>org.netbeans.modules.gsf</friend>
<friend>org.netbeans.modules.jvi</friend>
<friend>org.netbeans.modules.languages</friend>
<friend>org.netbeans.modules.markdown</friend>
<friend>org.netbeans.modules.options.editor</friend>
<friend>org.netbeans.modules.editor.fold</friend>
<friend>org.netbeans.modules.editor.fold.nbui</friend>
Expand Down
1 change: 1 addition & 0 deletions ide/libs.flexmark/external/binaries-list
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ A3F92ABD0ACBB4D1F12DFD3D6128F73D245D6BA9 com.vladsch.flexmark:flexmark-util-data
985913246DF64FE7E768EB0664B45DEDEA7536CF com.vladsch.flexmark:flexmark-util-sequence:0.64.8
A8178BA6DFD7A958353A60B3A51FE7EDB1578B49 com.vladsch.flexmark:flexmark-util-visitor:0.64.8
4ADC75ADA3D870908BDBFFB76650D19305250D3C com.vladsch.flexmark:flexmark-ext-gfm-tasklist:0.64.8
1851E124C6D85C5C7F3FDBBE066D30A76AD6BE44 com.vladsch.flexmark:flexmark-ext-gfm-strikethrough:0.64.8
CD56EB47DCD4590EF6451F87E5EC33BDDD1A9A51 org.jsoup:jsoup:1.15.4
2 changes: 1 addition & 1 deletion ide/libs.flexmark/external/flexmark-0.64.8-license.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Version: 0.64.8
License: BSD-flexmark
Description: FlexMark library
Origin: https://github.com/vsch/flexmark-java
Files: flexmark-0.64.8.jar flexmark-ext-anchorlink-0.64.8.jar flexmark-ext-emoji-0.64.8.jar flexmark-ext-tables-0.64.8.jar flexmark-html2md-converter-0.64.8.jar flexmark-util-ast-0.64.8.jar flexmark-util-builder-0.64.8.jar flexmark-util-collection-0.64.8.jar flexmark-util-data-0.64.8.jar flexmark-util-dependency-0.64.8.jar flexmark-util-format-0.64.8.jar flexmark-util-html-0.64.8.jar flexmark-util-misc-0.64.8.jar flexmark-util-sequence-0.64.8.jar flexmark-util-visitor-0.64.8.jar flexmark-ext-gfm-tasklist-0.64.8.jar
Files: flexmark-0.64.8.jar flexmark-ext-anchorlink-0.64.8.jar flexmark-ext-emoji-0.64.8.jar flexmark-ext-tables-0.64.8.jar flexmark-html2md-converter-0.64.8.jar flexmark-util-ast-0.64.8.jar flexmark-util-builder-0.64.8.jar flexmark-util-collection-0.64.8.jar flexmark-util-data-0.64.8.jar flexmark-util-dependency-0.64.8.jar flexmark-util-format-0.64.8.jar flexmark-util-html-0.64.8.jar flexmark-util-misc-0.64.8.jar flexmark-util-sequence-0.64.8.jar flexmark-util-visitor-0.64.8.jar flexmark-ext-gfm-tasklist-0.64.8.jar flexmark-ext-gfm-strikethrough-0.64.8.jar

Copyright (c) 2015-2016, Atlassian Pty Ltd
All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion ide/libs.flexmark/manifest.mf
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ Manifest-Version: 1.0
AutoUpdate-Show-In-Client: true
OpenIDE-Module: org.netbeans.libs.flexmark
OpenIDE-Module-Localizing-Bundle: org/netbeans/libs/flexmark/Bundle.properties
OpenIDE-Module-Specification-Version: 1.25
OpenIDE-Module-Specification-Version: 1.26

1 change: 1 addition & 0 deletions ide/libs.flexmark/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ release.external/flexmark-ext-emoji-0.64.8.jar=modules/ext/flexmark-ext-emoji-0.
release.external/flexmark-ext-anchorlink-0.64.8.jar=modules/ext/flexmark-ext-anchorlink-0.64.8.jar
release.external/flexmark-ext-tables-0.64.8.jar=modules/ext/flexmark-ext-tables-0.64.8.jar
release.external/flexmark-ext-gfm-tasklist-0.64.8.jar=modules/ext/flexmark-ext-gfm-tasklist-0.64.8.jar
release.external/flexmark-ext-gfm-strikethrough-0.64.8.jar=modules/ext/flexmark-ext-gfm-strikethrough-0.64.8.jar
release.external/jsoup-1.15.4.jar=modules/ext/jsoup-1.15.4.jar

# Sigtest seems to have issues with some Java 11 class files, better to disable it.
Expand Down
4 changes: 4 additions & 0 deletions ide/libs.flexmark/nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@
<runtime-relative-path>ext/flexmark-ext-gfm-tasklist-0.64.8.jar</runtime-relative-path>
<binary-origin>external/flexmark-ext-gfm-tasklist-0.64.8.jar</binary-origin>
</class-path-extension>
<class-path-extension>
<runtime-relative-path>ext/flexmark-ext-gfm-strikethrough-0.64.8.jar</runtime-relative-path>
<binary-origin>external/flexmark-ext-gfm-strikethrough-0.64.8.jar</binary-origin>
</class-path-extension>
</data>
</configuration>
</project>
7 changes: 6 additions & 1 deletion ide/markdown/licenseinfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,10 @@
<file>src/org/netbeans/modules/markdown/resources/Template.md</file>
<license ref="Apache-2.0-ASF" />
<comment type="TEMPLATE_MINIMAL_IP" />
</fileset>
</fileset>
<fileset>
<file>src/org/netbeans/modules/markdown/resources/Coloring.md</file>
<license ref="Apache-2.0-ASF" />
<comment type="TEMPLATE_MINIMAL_IP" />
</fileset>
</licenseinfo>
1 change: 1 addition & 0 deletions ide/markdown/manifest.mf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Manifest-Version: 1.0
AutoUpdate-Show-In-Client: true
OpenIDE-Module: org.netbeans.modules.markdown
OpenIDE-Module-Layer: org/netbeans/modules/markdown/resources/layer.xml
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/markdown/Bundle.properties
OpenIDE-Module-Specification-Version: 1.20

2 changes: 1 addition & 1 deletion ide/markdown/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
# specific language governing permissions and limitations
# under the License.

javac.source=1.8
javac.release=17
javac.compilerargs=-Xlint -Xlint:-serial
27 changes: 27 additions & 0 deletions ide/markdown/nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,33 @@
<specification-version>1.15</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.editor.mimelookup</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<release-version>1</release-version>
<specification-version>1.72</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.editor.settings</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<release-version>1</release-version>
<specification-version>1.89</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.editor.settings.storage</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<release-version>1</release-version>
<specification-version>1.84</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.textmate.lexer</code-name-base>
<build-prerequisite/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@
@GrammarRegistration(mimeType=MarkdownDataObject.MIME_TYPE, grammar="markdown.tmLanguage.json")
public class MarkdownDataObject extends MultiDataObject {

public static final String MIME_TYPE = "text/x-markdown-nb";
public static final String MIME_TYPE = "text/x-markdown";

public MarkdownDataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException, IOException {
super(pf, loader);
registerEditor("text/x-markdown", true);
registerEditor(MIME_TYPE, true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.netbeans.modules.markdown;

import com.vladsch.flexmark.ext.anchorlink.AnchorLinkExtension;
import com.vladsch.flexmark.ext.gfm.strikethrough.StrikethroughExtension;
import com.vladsch.flexmark.ext.gfm.tasklist.TaskListExtension;
import com.vladsch.flexmark.ext.tables.TablesExtension;
import com.vladsch.flexmark.html.HtmlRenderer;
Expand All @@ -27,6 +28,8 @@
import com.vladsch.flexmark.util.data.MutableDataSet;
import java.awt.BorderLayout;
import java.awt.Rectangle;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
Expand All @@ -49,6 +52,8 @@
import org.netbeans.core.spi.multiview.CloseOperationState;
import org.netbeans.core.spi.multiview.MultiViewElement;
import org.netbeans.core.spi.multiview.MultiViewElementCallback;
import org.netbeans.modules.editor.settings.storage.api.EditorSettings;
import static org.netbeans.modules.markdown.MarkdownDataObject.MIME_TYPE;
import org.netbeans.modules.markdown.ui.preview.MarkdownEditorKit;
import org.openide.awt.HtmlBrowser;
import org.openide.awt.UndoRedo;
Expand All @@ -62,6 +67,7 @@
import org.openide.util.NbBundle.Messages;
import org.openide.util.RequestProcessor;
import org.openide.util.RequestProcessor.Task;
import org.openide.util.WeakListeners;
import org.openide.windows.TopComponent;

/**
Expand All @@ -71,7 +77,7 @@
@MultiViewElement.Registration(
displayName = "#LBL_MarkdownViewer",
iconBase = "org/netbeans/modules/markdown/markdown.png",
mimeType = "text/x-markdown",
mimeType = MIME_TYPE,
persistenceType = TopComponent.PERSISTENCE_NEVER,
preferredID = "MarkdownViewer",
position = 2000
Expand All @@ -94,7 +100,8 @@ public class MarkdownViewerElement implements MultiViewElement {
.set(Parser.EXTENSIONS, Arrays.asList(
AnchorLinkExtension.create(),
TablesExtension.create(),
TaskListExtension.create()
TaskListExtension.create(),
StrikethroughExtension.create()
))
.set(HtmlRenderer.INDENT_SIZE, 2)
.set(HtmlRenderer.RENDER_HEADER_ID, true)
Expand All @@ -111,6 +118,9 @@ public class MarkdownViewerElement implements MultiViewElement {
.set(TablesExtension.APPEND_MISSING_COLUMNS, true)
.set(TablesExtension.DISCARD_EXTRA_COLUMNS, true)
.set(TablesExtension.HEADER_SEPARATOR_COLUMN_MATCH, true)
// Strikethrough change from del to s tag
.set(StrikethroughExtension.STRIKETHROUGH_STYLE_HTML_OPEN, "<s>") //NOI18N
.set(StrikethroughExtension.STRIKETHROUGH_STYLE_HTML_CLOSE, "</s>") //NOI18N
.toImmutable();

final Parser parser = Parser.builder(OPTIONS).build();
Expand All @@ -134,15 +144,21 @@ public void changedUpdate(DocumentEvent e) {
};

private final Task updater = RP.create(MarkdownViewerElement.this::updateView);

private StyledDocument source;

//Font config update listener
private volatile boolean fontChanged = false;
private final PropertyChangeListener pcl = this::colorProfileChange;

public MarkdownViewerElement(Lookup lookup) {
dataObject = lookup.lookup(MarkdownDataObject.class);
}

@Override
public JComponent getVisualRepresentation() {
if (component == null) {
EditorSettings.getDefault().addPropertyChangeListener(WeakListeners.propertyChange(pcl, this));
viewer = new JEditorPane();
viewer.setEditorKit(new MarkdownEditorKit());
viewer.setEditable(false);
Expand Down Expand Up @@ -289,4 +305,31 @@ private void linkHandler(HyperlinkEvent evt) {
}
}
}

/**
* redraw document if profile changes or font setting changes
* @param evt
*/
public void colorProfileChange(PropertyChangeEvent evt) {
if (viewer == null) {
return;
}

String newValue =(evt.getNewValue() instanceof String ) ? (String) evt.getNewValue() : ""; // NOI18N

//patch for triggering font update
if (!fontChanged &&
"fontColors".equals(evt.getPropertyName()) // NOI18N
&& evt.getOldValue() != null
&& !newValue.startsWith("test") // NOI18N
) {
fontChanged = true;
}

if (fontChanged || EditorSettings.PROP_CURRENT_FONT_COLOR_PROFILE.equals(evt.getPropertyName())) {
fontChanged = false;
viewer.setEditorKit(new MarkdownEditorKit());
updateView();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
"Once accepted there, we are happy to receive an update request."
],
"version": "https://github.com/microsoft/vscode-markdown-tm-grammar/commit/7418dd20d76c72e82fadee2909e03239e9973b35",
"version": "https://github.com/microsoft/vscode-markdown-tm-grammar/commit/548ccb91ef58ba40ac745b400d889933ccd5eb4d",
"name": "Markdown",
"scopeName": "text.html.markdown",
"patterns": [
Expand Down Expand Up @@ -3084,7 +3084,7 @@
"name": "punctuation.definition.strikethrough.markdown"
}
},
"match": "(?<!\\\\)(~{2,})((?:[^~]|(?!(?<![~\\\\])\\1(?!~))~)*+)(\\1)",
"match": "(?<!\\\\)(~{2,})(?!(?<=\\w~~)_)((?:[^~]|(?!(?<![~\\\\])\\1(?!~))~)*+)(\\1)(?!(<=_\\1)\\w)",
"name": "markup.strikethrough.markdown"
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

Editors/text/x-markdown=Markdown

Editors/text/x-markdown-preview=Markdown Preview

body = Body
heading1 = H1
heading2 = H2
heading3 = H3
heading4 = H4
heading5 = H5
heading6 = H6

pre = Code block
code = Inline code
blockquote = Block quote
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

=========================
```
COLORING PREVIEW NOT ENABLED
```
=========================

# Markdown Cheat Sheet (Example File)

This is a **generic Markdown template** showcasing essential formatting features.

---

## 1. Headers
# H1 (Largest)
## H2
### H3
#### H4
##### H5
###### H6 (Smallest)

---

## 2. Text Formatting
- **Bold** (`**text**` or `__text__`)
- *Italic* (`*text*` or `_text_`)
- ~~Strikethrough~~ (`~~text~~`)
- `Inline Code` (`` `code` ``)
- > Blockquote (prefix with `>`)

---

## 3. Lists
### Unordered List
- Item 1
- Item 2
- Nested Item (indent with 2 spaces)

### Ordered List
1. First item
2. Second item
1. Nested item (indent with 3 spaces)

### Task List
- [x] Completed task
- [ ] Pending task (`[ ]`)

---

## 4. Links
- [Hyperlink](https://example.com) (`[text](url)`)

---

## 5. Code Blocks
```java
# Syntax-highlighted block (java)
class HelloWorld {
public static main(String... args) {
System.out.println("Hello markdown");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.

-->
<!DOCTYPE fontscolors PUBLIC "-//NetBeans//DTD Editor Fonts and Colors settings 1.1//EN" "http://www.netbeans.org/dtds/EditorFontsColors-1_1.dtd">
<fontscolors>
<fontcolor name="body" default="default"/>
<fontcolor name="code" bgColor="38566F"/>
<fontcolor name="pre" bgColor="38566F"/>
<fontcolor name="heading1"/>
<fontcolor name="heading2" default="heading1"/>
<fontcolor name="heading3" default="heading1"/>
<fontcolor name="heading4" default="heading1"/>
<fontcolor name="heading5" default="heading1"/>
<fontcolor name="heading6" default="heading1"/>
</fontscolors>

Loading
Loading